182 if (!qFuzzyIsNull(vLengthSqr))
184 double mu = v.
dot(*
this-start)/vLengthSqr;
186 return (*
this-start).lengthSquared();
188 return (*
this-end).lengthSquared();
190 return ((start + mu*v)-*
this).lengthSquared();
192 return (*
this-start).lengthSquared();
288 mIsAntialiasing(false)
305 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) // before Qt5, default pens used to be cosmetic if NonCosmeticDefaultPen flag isn't set. So we set it to get consistency across Qt versions. 307 setRenderHint(QPainter::NonCosmeticDefaultPen);
319 QPainter::setPen(pen);
333 QPainter::setPen(color);
347 QPainter::setPen(penStyle);
363 QPainter::drawLine(line);
365 QPainter::drawLine(line.toLine());
376 setRenderHint(QPainter::Antialiasing, enabled);
385 translate(-0.5, -0.5);
412 bool result = QPainter::begin(device);
413 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) // before Qt5, default pens used to be cosmetic if NonCosmeticDefaultPen flag isn't set. So we set it to get consistency across Qt versions. 415 setRenderHint(QPainter::NonCosmeticDefaultPen);
427 if (!enabled &&
mModes.testFlag(mode))
429 else if (enabled && !
mModes.testFlag(mode))
460 qDebug() << Q_FUNC_INFO <<
"Unbalanced save/restore";
470 if (qFuzzyIsNull(pen().widthF()))
572 mDevicePixelRatio(devicePixelRatio),
631 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 635 qDebug() << Q_FUNC_INFO <<
"Device pixel ratios not supported for Qt versions before 5.4";
670 result->setRenderHint(QPainter::HighQualityAntialiasing);
677 if (painter && painter->isActive())
678 painter->drawPixmap(0, 0,
mBuffer);
680 qDebug() << Q_FUNC_INFO <<
"invalid or inactive painter passed";
695 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 697 mBuffer.setDevicePixelRatio(mDevicePixelRatio);
699 qDebug() << Q_FUNC_INFO <<
"Device pixel ratios not supported for Qt versions before 5.4";
700 mDevicePixelRatio = 1.0;
710 #ifdef QCP_OPENGL_PBUFFER 734 QCPPaintBufferGlPbuffer::QCPPaintBufferGlPbuffer(
const QSize &
size,
double devicePixelRatio,
int multisamples) :
737 mMultisamples(qMax(0, multisamples))
739 QCPPaintBufferGlPbuffer::reallocateBuffer();
742 QCPPaintBufferGlPbuffer::~QCPPaintBufferGlPbuffer()
749 QCPPainter *QCPPaintBufferGlPbuffer::startPainting()
751 if (!mGlPBuffer->isValid())
753 qDebug() << Q_FUNC_INFO <<
"OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?";
758 result->setRenderHint(QPainter::HighQualityAntialiasing);
763 void QCPPaintBufferGlPbuffer::draw(
QCPPainter *painter)
const 765 if (!painter || !painter->isActive())
767 qDebug() << Q_FUNC_INFO <<
"invalid or inactive painter passed";
770 if (!mGlPBuffer->isValid())
772 qDebug() << Q_FUNC_INFO <<
"OpenGL pbuffer isn't valid, reallocateBuffer was not called?";
775 painter->drawImage(0, 0, mGlPBuffer->toImage());
779 void QCPPaintBufferGlPbuffer::clear(
const QColor &color)
781 if (mGlPBuffer->isValid())
783 mGlPBuffer->makeCurrent();
784 glClearColor(color.redF(), color.greenF(), color.blueF(), color.alphaF());
785 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
786 mGlPBuffer->doneCurrent();
788 qDebug() << Q_FUNC_INFO <<
"OpenGL pbuffer invalid or context not current";
792 void QCPPaintBufferGlPbuffer::reallocateBuffer()
798 format.setAlpha(
true);
799 format.setSamples(mMultisamples);
800 mGlPBuffer =
new QGLPixelBuffer(
mSize, format);
802 #endif // QCP_OPENGL_PBUFFER 805 #ifdef QCP_OPENGL_FBO 830 QCPPaintBufferGlFbo::QCPPaintBufferGlFbo(
const QSize &
size,
double devicePixelRatio, QWeakPointer<QOpenGLContext> glContext, QWeakPointer<QOpenGLPaintDevice> glPaintDevice) :
832 mGlContext(glContext),
833 mGlPaintDevice(glPaintDevice),
836 QCPPaintBufferGlFbo::reallocateBuffer();
839 QCPPaintBufferGlFbo::~QCPPaintBufferGlFbo()
842 delete mGlFrameBuffer;
846 QCPPainter *QCPPaintBufferGlFbo::startPainting()
848 if (mGlPaintDevice.isNull())
850 qDebug() << Q_FUNC_INFO <<
"OpenGL paint device doesn't exist";
855 qDebug() << Q_FUNC_INFO <<
"OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?";
859 if (QOpenGLContext::currentContext() != mGlContext.data())
860 mGlContext.data()->makeCurrent(mGlContext.data()->surface());
861 mGlFrameBuffer->bind();
863 result->setRenderHint(QPainter::HighQualityAntialiasing);
868 void QCPPaintBufferGlFbo::donePainting()
870 if (mGlFrameBuffer && mGlFrameBuffer->isBound())
871 mGlFrameBuffer->release();
873 qDebug() << Q_FUNC_INFO <<
"Either OpenGL frame buffer not valid or was not bound";
877 void QCPPaintBufferGlFbo::draw(
QCPPainter *painter)
const 879 if (!painter || !painter->isActive())
881 qDebug() << Q_FUNC_INFO <<
"invalid or inactive painter passed";
886 qDebug() << Q_FUNC_INFO <<
"OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?";
889 painter->drawImage(0, 0, mGlFrameBuffer->toImage());
893 void QCPPaintBufferGlFbo::clear(
const QColor &color)
895 if (mGlContext.isNull())
897 qDebug() << Q_FUNC_INFO <<
"OpenGL context doesn't exist";
902 qDebug() << Q_FUNC_INFO <<
"OpenGL frame buffer object doesn't exist, reallocateBuffer was not called?";
906 if (QOpenGLContext::currentContext() != mGlContext.data())
907 mGlContext.data()->makeCurrent(mGlContext.data()->surface());
908 mGlFrameBuffer->bind();
909 glClearColor(color.redF(), color.greenF(), color.blueF(), color.alphaF());
910 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
911 mGlFrameBuffer->release();
915 void QCPPaintBufferGlFbo::reallocateBuffer()
920 if (mGlFrameBuffer->isBound())
921 mGlFrameBuffer->release();
922 delete mGlFrameBuffer;
926 if (mGlContext.isNull())
928 qDebug() << Q_FUNC_INFO <<
"OpenGL context doesn't exist";
931 if (mGlPaintDevice.isNull())
933 qDebug() << Q_FUNC_INFO <<
"OpenGL paint device doesn't exist";
938 mGlContext.data()->makeCurrent(mGlContext.data()->surface());
939 QOpenGLFramebufferObjectFormat frameBufferFormat;
940 frameBufferFormat.setSamples(mGlContext.data()->format().samples());
941 frameBufferFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
944 mGlPaintDevice.data()->setSize(
mSize*mDevicePixelRatio);
945 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 946 mGlPaintDevice.data()->setDevicePixelRatio(mDevicePixelRatio);
949 #endif // QCP_OPENGL_FBO 1043 QObject(parentPlot),
1044 mParentPlot(parentPlot),
1065 qDebug() << Q_FUNC_INFO <<
"The parent plot's mCurrentLayer will be a dangling pointer. Should have been set to a valid layer or 0 beforehand.";
1125 painter->setClipRect(child->
clipRect().translated(0, -1));
1127 child->
draw(painter);
1147 if (painter->isActive())
1150 qDebug() << Q_FUNC_INFO <<
"paint buffer returned inactive painter";
1154 qDebug() << Q_FUNC_INFO <<
"paint buffer returned zero painter";
1156 qDebug() << Q_FUNC_INFO <<
"no valid paint buffer associated with this layer";
1183 qDebug() << Q_FUNC_INFO <<
"no valid paint buffer associated with this layer";
1209 qDebug() << Q_FUNC_INFO <<
"layerable is already child of this layer" <<
reinterpret_cast<quintptr
>(layerable);
1228 qDebug() << Q_FUNC_INFO <<
"layerable is not child of this layer" <<
reinterpret_cast<quintptr
>(layerable);
1343 mParentLayerable(parentLayerable),
1349 if (targetLayer.isEmpty())
1352 qDebug() << Q_FUNC_INFO <<
"setting QCPlayerable initial layer to" << targetLayer <<
"failed.";
1398 qDebug() << Q_FUNC_INFO <<
"no parent QCustomPlot set";
1406 qDebug() << Q_FUNC_INFO <<
"there is no layer with name" << layerName;
1474 Q_UNUSED(onlySelectable)
1500 qDebug() << Q_FUNC_INFO <<
"called with mParentPlot already initialized";
1505 qDebug() << Q_FUNC_INFO <<
"called with parentPlot zero";
1539 qDebug() << Q_FUNC_INFO <<
"no parent QCustomPlot set";
1544 qDebug() << Q_FUNC_INFO <<
"layer" << layer->
name() <<
"is not in same QCustomPlot as this layerable";
1594 Q_UNUSED(parentPlot)
1663 Q_UNUSED(selectionStateChanged)
1680 Q_UNUSED(selectionStateChanged)
1950 lower = includeCoord;
1952 upper = includeCoord;
1969 result.
expand(otherRange);
1986 result.
expand(includeCoord);
2000 if (lowerBound > upperBound)
2001 qSwap(lowerBound, upperBound);
2004 if (result.
lower < lowerBound)
2006 result.
lower = lowerBound;
2008 if (result.
upper > upperBound || qFuzzyCompare(
size(), upperBound-lowerBound))
2009 result.
upper = upperBound;
2010 }
else if (result.
upper > upperBound)
2012 result.
upper = upperBound;
2014 if (result.
lower < lowerBound || qFuzzyCompare(
size(), upperBound-lowerBound))
2015 result.
lower = lowerBound;
2035 double rangeFac = 1e-3;
2040 if (sanitizedRange.
lower == 0.0 && sanitizedRange.
upper != 0.0)
2043 if (rangeFac < sanitizedRange.
upper*rangeFac)
2044 sanitizedRange.
lower = rangeFac;
2046 sanitizedRange.
lower = sanitizedRange.
upper*rangeFac;
2048 else if (sanitizedRange.
lower != 0.0 && sanitizedRange.
upper == 0.0)
2051 if (-rangeFac > sanitizedRange.
lower*rangeFac)
2052 sanitizedRange.
upper = -rangeFac;
2054 sanitizedRange.
upper = sanitizedRange.
lower*rangeFac;
2055 }
else if (sanitizedRange.
lower < 0 && sanitizedRange.
upper > 0)
2058 if (-sanitizedRange.
lower > sanitizedRange.
upper)
2061 if (-rangeFac > sanitizedRange.
lower*rangeFac)
2062 sanitizedRange.
upper = -rangeFac;
2064 sanitizedRange.
upper = sanitizedRange.
lower*rangeFac;
2068 if (rangeFac < sanitizedRange.
upper*rangeFac)
2069 sanitizedRange.
lower = rangeFac;
2071 sanitizedRange.
lower = sanitizedRange.
upper*rangeFac;
2075 return sanitizedRange;
2086 return sanitizedRange;
2103 !(lower > 0 && qIsInf(upper/lower)) &&
2104 !(upper < 0 && qIsInf(lower/upper)));
2392 mDataRanges.append(range);
2404 if (mDataRanges.size() != other.
mDataRanges.size())
2406 for (
int i=0; i<mDataRanges.size(); ++i)
2431 addDataRange(other);
2456 while (i < mDataRanges.size())
2458 const int thisBegin = mDataRanges.at(i).begin();
2459 const int thisEnd = mDataRanges.at(i).end();
2460 if (thisBegin >= other.
end())
2463 if (thisEnd > other.
begin())
2465 if (thisBegin >= other.
begin())
2467 if (thisEnd <= other.
end())
2469 mDataRanges.removeAt(i);
2472 mDataRanges[i].setBegin(other.
end());
2475 if (thisEnd <= other.
end())
2477 mDataRanges[i].setEnd(other.
begin());
2480 mDataRanges[i].setEnd(other.
begin());
2499 for (
int i=0; i<mDataRanges.size(); ++i)
2500 result += mDataRanges.at(i).length();
2514 if (index >= 0 && index < mDataRanges.size())
2516 return mDataRanges.at(index);
2519 qDebug() << Q_FUNC_INFO <<
"index out of range:" << index;
2533 return QCPDataRange(mDataRanges.first().begin(), mDataRanges.last().end());
2544 mDataRanges.append(dataRange);
2556 mDataRanges.clear();
2571 for (
int i=mDataRanges.size()-1; i>=0; --i)
2573 if (mDataRanges.at(i).isEmpty())
2574 mDataRanges.removeAt(i);
2576 if (mDataRanges.isEmpty())
2580 std::sort(mDataRanges.begin(), mDataRanges.end(), lessThanDataRangeBegin);
2584 while (i < mDataRanges.size())
2586 if (mDataRanges.at(i-1).end() >= mDataRanges.at(i).begin())
2588 mDataRanges[i-1].setEnd(qMax(mDataRanges.at(i-1).end(), mDataRanges.at(i).end()));
2589 mDataRanges.removeAt(i);
2612 mDataRanges.clear();
2623 if (!mDataRanges.isEmpty())
2625 if (mDataRanges.size() > 1)
2626 mDataRanges = QList<QCPDataRange>() << mDataRanges.first();
2627 if (mDataRanges.first().length() > 1)
2628 mDataRanges.first().setEnd(mDataRanges.first().begin()+1);
2634 mDataRanges = QList<QCPDataRange>() << span();
2653 if (other.
isEmpty())
return false;
2657 while (thisIndex < mDataRanges.size() && otherIndex < other.
mDataRanges.size())
2659 if (mDataRanges.at(thisIndex).contains(other.
mDataRanges.at(otherIndex)))
2664 return thisIndex < mDataRanges.size();
2678 for (
int i=0; i<mDataRanges.size(); ++i)
2679 result.
addDataRange(mDataRanges.at(i).intersection(other),
false);
2714 if (mDataRanges.first().begin() != fullRange.
begin())
2717 for (
int i=1; i<mDataRanges.size(); ++i)
2720 if (mDataRanges.last().end() != fullRange.
end())
2815 mPen(QBrush(Qt::gray), 0, Qt::DashLine),
2816 mBrush(Qt::NoBrush),
2840 qDebug() << Q_FUNC_INFO <<
"called with axis zero";
2888 mRect = QRect(event->pos(),
event->pos());
2900 mRect.setBottomRight(event->pos());
2913 mRect.setBottomRight(event->pos());
2926 if (event->key() == Qt::Key_Escape &&
mActive)
2950 painter->setBrush(
mBrush);
2951 painter->drawRect(
mRect);
3009 QObject(parentPlot),
3029 QHashIterator<QCP::MarginSide, QList<QCPLayoutElement*> > it(
mChildren);
3030 while (it.hasNext())
3033 if (!it.value().isEmpty())
3046 QHashIterator<QCP::MarginSide, QList<QCPLayoutElement*> > it(
mChildren);
3047 while (it.hasNext())
3050 const QList<QCPLayoutElement*>
elements = it.value();
3051 for (
int i=elements.size()-1; i>=0; --i)
3052 elements.at(i)->setMarginGroup(it.key(), 0);
3071 for (
int i=0; i<elements.size(); ++i)
3073 if (!elements.at(i)->autoMargins().testFlag(side))
3075 int m = qMax(elements.at(i)->calculateAutoMargin(side),
QCP::getMarginValue(elements.at(i)->minimumMargins(), side));
3093 qDebug() << Q_FUNC_INFO <<
"element is already child of this margin group side" <<
reinterpret_cast<quintptr
>(element);
3104 if (!
mChildren[side].removeOne(element))
3105 qDebug() << Q_FUNC_INFO <<
"element is not child of this margin group side" <<
reinterpret_cast<quintptr
>(element);
3179 mMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX),
3180 mSizeConstraintRect(scrInnerRect),
3182 mOuterRect(0, 0, 0, 0),
3183 mMargins(0, 0, 0, 0),
3184 mMinimumMargins(0, 0, 0, 0),
3366 QVector<QCP::MarginSide> sideVector;
3372 for (
int i=0; i<sideVector.size(); ++i)
3467 return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
3480 return QList<QCPLayoutElement*>();
3507 qDebug() << Q_FUNC_INFO <<
"parent plot not defined";
3656 const int elCount = elementCount();
3657 for (
int i=0; i<elCount; ++i)
3667 const int c = elementCount();
3668 QList<QCPLayoutElement*> result;
3669 #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) 3672 for (
int i=0; i<c; ++i)
3673 result.append(elementAt(i));
3676 for (
int i=0; i<c; ++i)
3679 result << result.at(i)->elements(recursive);
3746 for (
int i=elementCount()-1; i>=0; --i)
3764 if (QWidget *w = qobject_cast<QWidget*>(parent()))
3765 w->updateGeometry();
3766 else if (
QCPLayout *l = qobject_cast<QCPLayout*>(parent()))
3767 l->sizeConstraintsChanged();
3805 el->setParent(
this);
3810 qDebug() << Q_FUNC_INFO <<
"Null element passed";
3832 qDebug() << Q_FUNC_INFO <<
"Null element passed";
3866 if (maxSizes.size() != minSizes.size() || minSizes.size() != stretchFactors.size())
3868 qDebug() << Q_FUNC_INFO <<
"Passed vector sizes aren't equal:" << maxSizes << minSizes << stretchFactors;
3869 return QVector<int>();
3871 if (stretchFactors.isEmpty())
3872 return QVector<int>();
3873 int sectionCount = stretchFactors.size();
3874 QVector<double> sectionSizes(sectionCount);
3877 for (
int i=0; i<sectionCount; ++i)
3878 minSizeSum += minSizes.at(i);
3879 if (totalSize < minSizeSum)
3882 for (
int i=0; i<sectionCount; ++i)
3884 stretchFactors[i] = minSizes.at(i);
3889 QList<int> minimumLockedSections;
3890 QList<int> unfinishedSections;
3891 for (
int i=0; i<sectionCount; ++i)
3892 unfinishedSections.append(i);
3893 double freeSize = totalSize;
3895 int outerIterations = 0;
3896 while (!unfinishedSections.isEmpty() && outerIterations < sectionCount*2)
3899 int innerIterations = 0;
3900 while (!unfinishedSections.isEmpty() && innerIterations < sectionCount*2)
3905 double nextMax = 1e12;
3906 for (
int i=0; i<unfinishedSections.size(); ++i)
3908 int secId = unfinishedSections.at(i);
3909 double hitsMaxAt = (maxSizes.at(secId)-sectionSizes.at(secId))/stretchFactors.at(secId);
3910 if (hitsMaxAt < nextMax)
3912 nextMax = hitsMaxAt;
3918 double stretchFactorSum = 0;
3919 for (
int i=0; i<unfinishedSections.size(); ++i)
3920 stretchFactorSum += stretchFactors.at(unfinishedSections.at(i));
3921 double nextMaxLimit = freeSize/stretchFactorSum;
3922 if (nextMax < nextMaxLimit)
3924 for (
int i=0; i<unfinishedSections.size(); ++i)
3926 sectionSizes[unfinishedSections.at(i)] += nextMax*stretchFactors.at(unfinishedSections.at(i));
3927 freeSize -= nextMax*stretchFactors.at(unfinishedSections.at(i));
3929 unfinishedSections.removeOne(nextId);
3932 for (
int i=0; i<unfinishedSections.size(); ++i)
3933 sectionSizes[unfinishedSections.at(i)] += nextMaxLimit*stretchFactors.at(unfinishedSections.at(i));
3934 unfinishedSections.clear();
3937 if (innerIterations == sectionCount*2)
3938 qDebug() << Q_FUNC_INFO <<
"Exceeded maximum expected inner iteration count, layouting aborted. Input was:" << maxSizes << minSizes << stretchFactors << totalSize;
3941 bool foundMinimumViolation =
false;
3942 for (
int i=0; i<sectionSizes.size(); ++i)
3944 if (minimumLockedSections.contains(i))
3946 if (sectionSizes.at(i) < minSizes.at(i))
3948 sectionSizes[i] = minSizes.at(i);
3949 foundMinimumViolation =
true;
3950 minimumLockedSections.append(i);
3953 if (foundMinimumViolation)
3955 freeSize = totalSize;
3956 for (
int i=0; i<sectionCount; ++i)
3958 if (!minimumLockedSections.contains(i))
3959 unfinishedSections.append(i);
3961 freeSize -= sectionSizes.at(i);
3964 for (
int i=0; i<unfinishedSections.size(); ++i)
3965 sectionSizes[unfinishedSections.at(i)] = 0;
3968 if (outerIterations == sectionCount*2)
3969 qDebug() << Q_FUNC_INFO <<
"Exceeded maximum expected outer iteration count, layouting aborted. Input was:" << maxSizes << minSizes << stretchFactors << totalSize;
3971 QVector<int> result(sectionCount);
3972 for (
int i=0; i<sectionCount; ++i)
3973 result[i] = qRound(sectionSizes.at(i));
3994 minOuter.rwidth() += el->
margins().left() + el->
margins().right();
3996 minOuter.rheight() += el->
margins().top() + el->
margins().bottom();
3998 return QSize(minOuter.width() > 0 ? minOuter.width() : minOuterHint.width(),
3999 minOuter.height() > 0 ? minOuter.height() : minOuterHint.height());;
4019 maxOuter.rwidth() += el->
margins().left() + el->
margins().right();
4021 maxOuter.rheight() += el->
margins().top() + el->
margins().bottom();
4023 return QSize(maxOuter.width() < QWIDGETSIZE_MAX ? maxOuter.width() : maxOuterHint.width(),
4024 maxOuter.height() < QWIDGETSIZE_MAX ? maxOuter.height() : maxOuterHint.height());
4077 mFillOrder(foRowsFirst)
4100 if (column >= 0 && column <
mElements.first().size())
4105 qDebug() << Q_FUNC_INFO <<
"Requested cell is empty. Row:" << row <<
"Column:" << column;
4107 qDebug() << Q_FUNC_INFO <<
"Invalid column. Row:" << row <<
"Column:" << column;
4109 qDebug() << Q_FUNC_INFO <<
"Invalid row. Row:" << row <<
"Column:" << column;
4132 if (element && element->
layout())
4140 qDebug() << Q_FUNC_INFO <<
"There is already an element in the specified row/column:" << row << column;
4181 return addElement(rowIndex, colIndex, element);
4217 qDebug() << Q_FUNC_INFO <<
"Invalid stretch factor, must be positive:" << factor;
4219 qDebug() << Q_FUNC_INFO <<
"Invalid column:" << column;
4243 qDebug() << Q_FUNC_INFO <<
"Invalid stretch factor, must be positive:" <<
mColumnStretchFactors.at(i);
4248 qDebug() << Q_FUNC_INFO <<
"Column count not equal to passed stretch factor count:" << factors;
4270 qDebug() << Q_FUNC_INFO <<
"Invalid stretch factor, must be positive:" << factor;
4272 qDebug() << Q_FUNC_INFO <<
"Invalid row:" << row;
4296 qDebug() << Q_FUNC_INFO <<
"Invalid stretch factor, must be positive:" <<
mRowStretchFactors.at(i);
4301 qDebug() << Q_FUNC_INFO <<
"Row count not equal to passed stretch factor count:" << factors;
4343 mWrap = qMax(0, count);
4374 QVector<QCPLayoutElement*> tempElements;
4377 tempElements.reserve(elCount);
4378 for (
int i=0; i<elCount; ++i)
4381 tempElements.append(
takeAt(i));
4390 for (
int i=0; i<tempElements.size(); ++i)
4414 mElements.append(QList<QCPLayoutElement*>());
4418 int newColCount = qMax(
columnCount(), newColumnCount);
4421 while (
mElements.at(i).size() < newColCount)
4448 QList<QCPLayoutElement*> newRow;
4475 for (
int row=0; row<
rowCount(); ++row)
4504 qDebug() << Q_FUNC_INFO <<
"row index out of bounds:" << row;
4506 qDebug() << Q_FUNC_INFO <<
"column index out of bounds:" << column;
4531 if (nCols == 0 || nRows == 0)
4535 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
4543 column = index / nRows;
4544 row = index % nRows;
4549 row = index / nCols;
4550 column = index % nCols;
4559 QVector<int> minColWidths, minRowHeights, maxColWidths, maxRowHeights;
4569 int yOffset =
mRect.top();
4570 for (
int row=0; row<
rowCount(); ++row)
4574 int xOffset =
mRect.left();
4580 mElements.at(row).at(col)->setOuterRect(QRect(xOffset, yOffset, colWidths.at(col), rowHeights.at(row)));
4623 qDebug() << Q_FUNC_INFO <<
"Attempt to take invalid index:" << index;
4641 qDebug() << Q_FUNC_INFO <<
"Element not in this layout, couldn't take";
4643 qDebug() << Q_FUNC_INFO <<
"Can't take null element";
4650 QList<QCPLayoutElement*> result;
4652 #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) 4653 result.reserve(elCount);
4655 for (
int i=0; i<elCount; ++i)
4659 for (
int i=0; i<elCount; ++i)
4662 result << result.at(i)->elements(recursive);
4674 for (
int row=
rowCount()-1; row>=0; --row)
4676 bool hasElements =
false;
4697 bool hasElements =
false;
4698 for (
int row=0; row<
rowCount(); ++row)
4709 for (
int row=0; row<
rowCount(); ++row)
4718 QVector<int> minColWidths, minRowHeights;
4721 for (
int i=0; i<minColWidths.size(); ++i)
4722 result.rwidth() += minColWidths.at(i);
4723 for (
int i=0; i<minRowHeights.size(); ++i)
4724 result.rheight() += minRowHeights.at(i);
4735 QVector<int> maxColWidths, maxRowHeights;
4739 for (
int i=0; i<maxColWidths.size(); ++i)
4740 result.setWidth(qMin(result.width()+maxColWidths.at(i), QWIDGETSIZE_MAX));
4741 for (
int i=0; i<maxRowHeights.size(); ++i)
4742 result.setHeight(qMin(result.height()+maxRowHeights.at(i), QWIDGETSIZE_MAX));
4747 if (result.height() > QWIDGETSIZE_MAX)
4748 result.setHeight(QWIDGETSIZE_MAX);
4749 if (result.width() > QWIDGETSIZE_MAX)
4750 result.setWidth(QWIDGETSIZE_MAX);
4770 *minRowHeights = QVector<int>(
rowCount(), 0);
4771 for (
int row=0; row<
rowCount(); ++row)
4778 if (minColWidths->at(col) < minSize.width())
4779 (*minColWidths)[col] = minSize.width();
4780 if (minRowHeights->at(row) < minSize.height())
4781 (*minRowHeights)[row] = minSize.height();
4802 *maxColWidths = QVector<int>(
columnCount(), QWIDGETSIZE_MAX);
4803 *maxRowHeights = QVector<int>(
rowCount(), QWIDGETSIZE_MAX);
4804 for (
int row=0; row<
rowCount(); ++row)
4811 if (maxColWidths->at(col) > maxSize.width())
4812 (*maxColWidths)[col] = maxSize.width();
4813 if (maxRowHeights->at(row) > maxSize.height())
4814 (*maxRowHeights)[row] = maxSize.height();
4872 return mInsetPlacement.at(index);
4875 qDebug() << Q_FUNC_INFO <<
"Invalid element index:" << index;
4887 return mInsetAlignment.at(index);
4890 qDebug() << Q_FUNC_INFO <<
"Invalid element index:" << index;
4902 return mInsetRect.at(index);
4905 qDebug() << Q_FUNC_INFO <<
"Invalid element index:" << index;
4918 mInsetPlacement[index] = placement;
4920 qDebug() << Q_FUNC_INFO <<
"Invalid element index:" << index;
4934 mInsetAlignment[index] = alignment;
4936 qDebug() << Q_FUNC_INFO <<
"Invalid element index:" << index;
4953 mInsetRect[index] =
rect;
4955 qDebug() << Q_FUNC_INFO <<
"Invalid element index:" << index;
4967 if (mInsetPlacement.at(i) == ipFree)
4969 insetRect = QRect(
rect().x()+
rect().width()*mInsetRect.at(i).x(),
4970 rect().y()+
rect().height()*mInsetRect.at(i).y(),
4971 rect().width()*mInsetRect.at(i).width(),
4972 rect().height()*mInsetRect.at(i).height());
4973 if (insetRect.size().width() < finalMinSize.width())
4974 insetRect.setWidth(finalMinSize.width());
4975 if (insetRect.size().height() < finalMinSize.height())
4976 insetRect.setHeight(finalMinSize.height());
4977 if (insetRect.size().width() > finalMaxSize.width())
4978 insetRect.setWidth(finalMaxSize.width());
4979 if (insetRect.size().height() > finalMaxSize.height())
4980 insetRect.setHeight(finalMaxSize.height());
4981 }
else if (mInsetPlacement.at(i) == ipBorderAligned)
4983 insetRect.setSize(finalMinSize);
4984 Qt::Alignment al = mInsetAlignment.at(i);
4985 if (al.testFlag(Qt::AlignLeft)) insetRect.moveLeft(
rect().x());
4986 else if (al.testFlag(Qt::AlignRight)) insetRect.moveRight(
rect().x()+
rect().width());
4987 else insetRect.moveLeft(
rect().x()+
rect().width()*0.5-finalMinSize.width()*0.5);
4988 if (al.testFlag(Qt::AlignTop)) insetRect.moveTop(
rect().y());
4989 else if (al.testFlag(Qt::AlignBottom)) insetRect.moveBottom(
rect().y()+
rect().height());
4990 else insetRect.moveTop(
rect().y()+
rect().height()*0.5-finalMinSize.height()*0.5);
4992 mElements.at(i)->setOuterRect(insetRect);
5005 if (index >= 0 && index <
mElements.size())
5018 mInsetPlacement.removeAt(index);
5019 mInsetAlignment.removeAt(index);
5020 mInsetRect.removeAt(index);
5024 qDebug() << Q_FUNC_INFO <<
"Attempt to take invalid index:" << index;
5042 qDebug() << Q_FUNC_INFO <<
"Element not in this layout, couldn't take";
5044 qDebug() << Q_FUNC_INFO <<
"Can't take null element";
5067 if (
mElements.at(i)->realVisibility() &&
mElements.at(i)->selectTest(pos, onlySelectable) >= 0)
5091 mInsetPlacement.append(ipBorderAligned);
5092 mInsetAlignment.append(alignment);
5093 mInsetRect.append(QRectF(0.6, 0.6, 0.4, 0.4));
5096 qDebug() << Q_FUNC_INFO <<
"Can't add null element";
5117 mInsetPlacement.append(ipFree);
5118 mInsetAlignment.append(Qt::AlignRight|Qt::AlignTop);
5119 mInsetRect.append(rect);
5122 qDebug() << Q_FUNC_INFO <<
"Can't add null element";
5303 QPen penBackup = painter->pen();
5304 QBrush brushBackup = painter->brush();
5305 QPen miterPen = penBackup;
5306 miterPen.setJoinStyle(Qt::MiterJoin);
5307 QBrush brush(painter->pen().color(), Qt::SolidPattern);
5313 QPointF points[3] = {pos.
toPointF(),
5314 (pos-lengthVec+widthVec).toPointF(),
5315 (pos-lengthVec-widthVec).toPointF()
5317 painter->
setPen(miterPen);
5318 painter->setBrush(brush);
5319 painter->drawConvexPolygon(points, 3);
5320 painter->setBrush(brushBackup);
5321 painter->
setPen(penBackup);
5326 QPointF points[4] = {pos.
toPointF(),
5327 (pos-lengthVec+widthVec).toPointF(),
5328 (pos-lengthVec*0.8).toPointF(),
5329 (pos-lengthVec-widthVec).toPointF()
5331 painter->
setPen(miterPen);
5332 painter->setBrush(brush);
5333 painter->drawConvexPolygon(points, 4);
5334 painter->setBrush(brushBackup);
5335 painter->
setPen(penBackup);
5340 QPointF points[3] = {(pos-lengthVec+widthVec).toPointF(),
5342 (pos-lengthVec-widthVec).toPointF()
5344 painter->
setPen(miterPen);
5345 painter->drawPolyline(points, 3);
5346 painter->
setPen(penBackup);
5351 painter->setBrush(brush);
5353 painter->setBrush(brushBackup);
5359 QPointF points[4] = {(pos-widthVecPerp+widthVec).toPointF(),
5360 (pos-widthVecPerp-widthVec).toPointF(),
5361 (pos+widthVecPerp-widthVec).toPointF(),
5362 (pos+widthVecPerp+widthVec).toPointF()
5364 painter->
setPen(miterPen);
5365 painter->setBrush(brush);
5366 painter->drawConvexPolygon(points, 4);
5367 painter->setBrush(brushBackup);
5368 painter->
setPen(penBackup);
5374 QPointF points[4] = {(pos-widthVecPerp).toPointF(),
5375 (pos-widthVec).toPointF(),
5376 (pos+widthVecPerp).toPointF(),
5377 (pos+widthVec).toPointF()
5379 painter->
setPen(miterPen);
5380 painter->setBrush(brush);
5381 painter->drawConvexPolygon(points, 4);
5382 painter->setBrush(brushBackup);
5383 painter->
setPen(penBackup);
5388 painter->
drawLine((pos+widthVec).toPointF(), (pos-widthVec).toPointF());
5402 (pos-widthVec-lengthVec*0.2*(
mInverted?-1:1)).toPointF());
5406 painter->
drawLine((pos+widthVec+lengthVec*0.2*(
mInverted?-1:1)+dir.
normalized()*qMax(1.0f, (
float)painter->pen().widthF())*0.5f).toPointF(),
5407 (pos-widthVec-lengthVec*0.2*(
mInverted?-1:1)+dir.
normalized()*qMax(1.0f, (
float)painter->pen().widthF())*0.5f).toPointF());
5490 mTickStepStrategy(tssReadability),
5523 qDebug() << Q_FUNC_INFO <<
"tick count must be greater than zero:" << count;
5552 void QCPAxisTicker::generate(
const QCPRange &range,
const QLocale &locale, QChar formatChar,
int precision, QVector<double> &ticks, QVector<double> *subTicks, QVector<QString> *tickLabels)
5562 if (ticks.size() > 0)
5567 *subTicks = QVector<double>();
5605 double epsilon = 0.01;
5608 double fracPart = modf(
getMantissa(tickStep), &intPartf);
5612 if (fracPart < epsilon || 1.0-fracPart < epsilon)
5614 if (1.0-fracPart < epsilon)
5618 case 1: result = 4;
break;
5619 case 2: result = 3;
break;
5620 case 3: result = 2;
break;
5621 case 4: result = 3;
break;
5622 case 5: result = 4;
break;
5623 case 6: result = 2;
break;
5624 case 7: result = 6;
break;
5625 case 8: result = 3;
break;
5626 case 9: result = 2;
break;
5631 if (qAbs(fracPart-0.5) < epsilon)
5635 case 1: result = 2;
break;
5636 case 2: result = 4;
break;
5637 case 3: result = 4;
break;
5638 case 4: result = 2;
break;
5639 case 5: result = 4;
break;
5640 case 6: result = 4;
break;
5641 case 7: result = 2;
break;
5642 case 8: result = 4;
break;
5643 case 9: result = 4;
break;
5665 return locale.toString(tick, formatChar.toLatin1(), precision);
5679 QVector<double> result;
5680 if (subTickCount <= 0 || ticks.size() < 2)
5683 result.reserve((ticks.size()-1)*subTickCount);
5684 for (
int i=1; i<ticks.size(); ++i)
5686 double subTickStep = (ticks.at(i)-ticks.at(i-1))/(
double)(subTickCount+1);
5687 for (
int k=1; k<=subTickCount; ++k)
5688 result.append(ticks.at(i-1) + k*subTickStep);
5710 QVector<double> result;
5714 int tickcount = lastStep-firstStep+1;
5715 if (tickcount < 0) tickcount = 0;
5716 result.resize(tickcount);
5717 for (
int i=0; i<tickcount; ++i)
5733 QVector<QString> result;
5734 result.reserve(ticks.size());
5735 for (
int i=0; i<ticks.size(); ++i)
5736 result.append(
getTickLabel(ticks.at(i), locale, formatChar, precision));
5749 bool lowFound =
false;
5750 bool highFound =
false;
5754 for (
int i=0; i < ticks.size(); ++i)
5756 if (ticks.at(i) >= range.
lower)
5763 for (
int i=ticks.size()-1; i >= 0; --i)
5765 if (ticks.at(i) <= range.
upper)
5773 if (highFound && lowFound)
5775 int trimFront = qMax(0, lowIndex-(keepOneOutlier ? 1 : 0));
5776 int trimBack = qMax(0, ticks.size()-(keepOneOutlier ? 2 : 1)-highIndex);
5777 if (trimFront > 0 || trimBack > 0)
5778 ticks = ticks.mid(trimFront, ticks.size()-trimFront-trimBack);
5791 if (candidates.size() == 1)
5792 return candidates.first();
5793 QVector<double>::const_iterator it = std::lower_bound(candidates.constBegin(), candidates.constEnd(), target);
5794 if (it == candidates.constEnd())
5796 else if (it == candidates.constBegin())
5799 return target-*(it-1) < *it-target ? *(it-1) : *it;
5811 const double mag = qPow(10.0, qFloor(qLn(input)/qLn(10.0)));
5812 if (magnitude) *magnitude = mag;
5825 const double mantissa =
getMantissa(input, &magnitude);
5830 return pickClosest(mantissa, QVector<double>() << 1.0 << 2.0 << 2.5 << 5.0 << 10.0)*magnitude;
5835 if (mantissa <= 5.0)
5836 return (
int)(mantissa*2)/2.0*magnitude;
5838 return (
int)(mantissa/2.0)*2.0*magnitude;
5893 mDateTimeFormat(QLatin1String(
"hh:mm:ss\ndd.MM.yy")),
5894 mDateTimeSpec(Qt::LocalTime),
5895 mDateStrategy(dsNone)
5975 }
else if (result < 86400*30.4375*12)
5978 << 1 << 2.5 << 5 << 10 << 15 << 30 << 60 << 2.5*60 << 5*60 << 10*60 << 15*60 << 30*60 << 60*60
5979 << 3600*2 << 3600*3 << 3600*6 << 3600*12 << 3600*24
5980 << 86400*2 << 86400*5 << 86400*7 << 86400*14 << 86400*30.4375 << 86400*30.4375*2 << 86400*30.4375*3 << 86400*30.4375*6 << 86400*30.4375*12);
5981 if (result > 86400*30.4375-1)
5983 else if (result > 3600*24-1)
5987 const double secondsPerYear = 86400*30.4375*12;
5988 result =
cleanMantissa(result/secondsPerYear)*secondsPerYear;
6004 switch (qRound(tickStep))
6006 case 5*60: result = 4;
break;
6007 case 10*60: result = 1;
break;
6008 case 15*60: result = 2;
break;
6009 case 30*60: result = 1;
break;
6010 case 60*60: result = 3;
break;
6011 case 3600*2: result = 3;
break;
6012 case 3600*3: result = 2;
break;
6013 case 3600*6: result = 1;
break;
6014 case 3600*12: result = 3;
break;
6015 case 3600*24: result = 3;
break;
6016 case 86400*2: result = 1;
break;
6017 case 86400*5: result = 4;
break;
6018 case 86400*7: result = 6;
break;
6019 case 86400*14: result = 1;
break;
6020 case (
int)(86400*30.4375+0.5): result = 3;
break;
6021 case (
int)(86400*30.4375*2+0.5): result = 1;
break;
6022 case (
int)(86400*30.4375*3+0.5): result = 2;
break;
6023 case (
int)(86400*30.4375*6+0.5): result = 5;
break;
6024 case (
int)(86400*30.4375*12+0.5): result = 3;
break;
6039 Q_UNUSED(formatChar)
6053 if (!result.isEmpty())
6058 QDateTime tickDateTime;
6059 for (
int i=0; i<result.size(); ++i)
6062 tickDateTime.setTime(uniformDateTime.time());
6068 QDateTime tickDateTime;
6069 for (
int i=0; i<result.size(); ++i)
6072 tickDateTime.setTime(uniformDateTime.time());
6073 int thisUniformDay = uniformDateTime.date().day() <= tickDateTime.date().daysInMonth() ? uniformDateTime.date().day() : tickDateTime.date().daysInMonth();
6074 if (thisUniformDay-tickDateTime.date().day() < -15)
6075 tickDateTime = tickDateTime.addMonths(1);
6076 else if (thisUniformDay-tickDateTime.date().day() > 15)
6077 tickDateTime = tickDateTime.addMonths(-1);
6078 tickDateTime.setDate(QDate(tickDateTime.date().year(), tickDateTime.date().month(), thisUniformDay));
6097 # if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) 6098 return QDateTime::fromTime_t(key).addMSecs((key-(qint64)key)*1000);
6100 return QDateTime::fromMSecsSinceEpoch(key*1000.0);
6117 # if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) 6118 return dateTime.toTime_t()+dateTime.time().msec()/1000.0;
6120 return dateTime.toMSecsSinceEpoch()/1000.0;
6134 # if QT_VERSION < QT_VERSION_CHECK(4, 7, 0) 6135 return QDateTime(date).toTime_t();
6137 return QDateTime(date).toMSecsSinceEpoch()/1000.0;
6190 mTimeFormat(QLatin1String(
"%h:%m:%s")),
6191 mSmallestUnit(tuSeconds),
6192 mBiggestUnit(tuHours)
6234 bool hasSmallest =
false;
6281 }
else if (result < 3600*24)
6284 QVector<double> availableSteps;
6287 availableSteps << 1;
6289 availableSteps << 2.5;
6291 availableSteps << 2;
6293 availableSteps << 5 << 10 << 15 << 30;
6296 availableSteps << 1*60;
6298 availableSteps << 2.5*60;
6300 availableSteps << 2*60;
6302 availableSteps << 5*60 << 10*60 << 15*60 << 30*60;
6305 availableSteps << 1*3600 << 2*3600 << 3*3600 << 6*3600 << 12*3600 << 24*3600;
6310 const double secondsPerDay = 3600*24;
6325 switch (qRound(tickStep))
6327 case 5*60: result = 4;
break;
6328 case 10*60: result = 1;
break;
6329 case 15*60: result = 2;
break;
6330 case 30*60: result = 1;
break;
6331 case 60*60: result = 3;
break;
6332 case 3600*2: result = 3;
break;
6333 case 3600*3: result = 2;
break;
6334 case 3600*6: result = 1;
break;
6335 case 3600*12: result = 3;
break;
6336 case 3600*24: result = 3;
break;
6351 Q_UNUSED(formatChar)
6353 bool negative = tick < 0;
6354 if (negative) tick *= -1;
6356 double restValues[
tuDays+1];
6361 values[
tuMinutes] = modf(restValues[tuMinutes]/60, &restValues[
tuHours])*60;
6362 values[
tuHours] = modf(restValues[tuHours]/24, &restValues[
tuDays])*24;
6372 result.prepend(QLatin1Char(
'-'));
6383 QString valueStr = QString::number(value);
6385 valueStr.prepend(QLatin1Char(
'0'));
6424 mScaleStrategy(ssNone)
6442 qDebug() << Q_FUNC_INFO <<
"tick step must be greater than zero:" << step;
6581 qDebug() << Q_FUNC_INFO <<
"sub tick count can't be negative:" << subTicks;
6605 mTicks.insert(position, label);
6636 if (positions.size() != labels.size())
6637 qDebug() << Q_FUNC_INFO <<
"passed unequal length vectors for positions and labels:" << positions.size() << labels.size();
6638 int n = qMin(positions.size(), labels.size());
6639 for (
int i=0; i<n; ++i)
6640 mTicks.insert(positions.at(i), labels.at(i));
6675 Q_UNUSED(formatChar)
6677 return mTicks.value(tick);
6690 QVector<double> result;
6694 QMap<double, QString>::const_iterator start =
mTicks.lowerBound(range.
lower);
6695 QMap<double, QString>::const_iterator end =
mTicks.upperBound(range.
upper);
6697 if (start !=
mTicks.constBegin()) --start;
6698 if (end !=
mTicks.constEnd()) ++end;
6699 for (QMap<double, QString>::const_iterator it = start; it != end; ++it)
6700 result.append(it.key());
6734 mPiSymbol(QLatin1String(
" ")+QChar(0x03C0)),
6737 mFractionStyle(fsUnicodeFractions),
6833 int denominator = 1000;
6834 int numerator = qRound(tickInPis*denominator);
6836 if (qAbs(numerator) == 1 && denominator == 1)
6837 return (numerator < 0 ? QLatin1String(
"-") : QLatin1String(
"")) +
mPiSymbol.trimmed();
6838 else if (numerator == 0)
6839 return QLatin1String(
"0");
6844 if (qFuzzyIsNull(tickInPis))
6845 return QLatin1String(
"0");
6846 else if (qFuzzyCompare(qAbs(tickInPis), 1.0))
6847 return (tickInPis < 0 ? QLatin1String(
"-") : QLatin1String(
"")) +
mPiSymbol.trimmed();
6861 if (numerator == 0 || denominator == 0)
6864 int num = numerator;
6865 int denom = denominator;
6868 int oldDenom = denom;
6869 denom = num % denom;
6888 if (denominator == 0)
6890 qDebug() << Q_FUNC_INFO <<
"called with zero denominator";
6895 qDebug() << Q_FUNC_INFO <<
"shouldn't be called with fraction style fsDecimal";
6896 return QString::number(numerator/(
double)denominator);
6898 int sign = numerator*denominator < 0 ? -1 : 1;
6899 numerator = qAbs(numerator);
6900 denominator = qAbs(denominator);
6902 if (denominator == 1)
6904 return QString::number(sign*numerator);
6907 int integerPart = numerator/denominator;
6908 int remainder = numerator%denominator;
6911 return QString::number(sign*integerPart);
6916 return QString(QLatin1String(
"%1%2%3/%4"))
6917 .arg(sign == -1 ? QLatin1String(
"-") : QLatin1String(
""))
6918 .arg(integerPart > 0 ? QString::number(integerPart)+QLatin1String(
" ") : QLatin1String(
""))
6923 return QString(QLatin1String(
"%1%2%3"))
6924 .arg(sign == -1 ? QLatin1String(
"-") : QLatin1String(
""))
6925 .arg(integerPart > 0 ? QString::number(integerPart) : QLatin1String(
""))
6955 return QString(QChar(0x2070));
6960 const int digit = number%10;
6963 case 1: { result.prepend(QChar(0x00B9));
break; }
6964 case 2: { result.prepend(QChar(0x00B2));
break; }
6965 case 3: { result.prepend(QChar(0x00B3));
break; }
6966 default: { result.prepend(QChar(0x2070+digit));
break; }
6981 return QString(QChar(0x2080));
6986 result.prepend(QChar(0x2080+number%10));
7027 mLogBaseLnInv(1.0/qLn(mLogBase))
7042 qDebug() << Q_FUNC_INFO <<
"log base has to be greater than zero:" << base;
7060 qDebug() << Q_FUNC_INFO <<
"sub tick count can't be negative:" << subTicks;
7102 QVector<double> result;
7107 double currentTick = qPow(newLogBase, qFloor(qLn(range.
lower)/qLn(newLogBase)));
7108 result.append(currentTick);
7109 while (currentTick < range.upper && currentTick > 0)
7111 currentTick *= newLogBase;
7112 result.append(currentTick);
7114 }
else if (range.
lower < 0 && range.
upper < 0)
7118 double currentTick = -qPow(newLogBase, qCeil(qLn(-range.
lower)/qLn(newLogBase)));
7119 result.append(currentTick);
7120 while (currentTick < range.
upper && currentTick < 0)
7122 currentTick /= newLogBase;
7123 result.append(currentTick);
7127 qDebug() << Q_FUNC_INFO <<
"Invalid range for logarithmic plot: " << range.
lower <<
".." << range.
upper;
7162 QCPLayerable(parentAxis->parentPlot(), QString(), parentAxis),
7163 mParentAxis(parentAxis)
7166 setParent(parentAxis);
7167 setPen(QPen(QColor(200,200,200), 0, Qt::DotLine));
7254 if (!
mParentAxis) { qDebug() << Q_FUNC_INFO <<
"invalid parent axis";
return; }
7269 if (!
mParentAxis) { qDebug() << Q_FUNC_INFO <<
"invalid parent axis";
return; }
7276 int zeroLineIndex = -1;
7282 for (
int i=0; i<tickCount; ++i)
7296 for (
int i=0; i<tickCount; ++i)
7298 if (i == zeroLineIndex)
continue;
7305 int zeroLineIndex = -1;
7311 for (
int i=0; i<tickCount; ++i)
7325 for (
int i=0; i<tickCount; ++i)
7327 if (i == zeroLineIndex)
continue;
7342 if (!
mParentAxis) { qDebug() << Q_FUNC_INFO <<
"invalid parent axis";
return; }
7505 mOrientation(orientation(type)),
7506 mSelectableParts(spAxis | spTickLabels | spAxisLabel),
7507 mSelectedParts(spNone),
7508 mBasePen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
7509 mSelectedBasePen(QPen(Qt::blue, 2)),
7513 mSelectedLabelFont(QFont(mLabelFont.family(), mLabelFont.pointSize(), QFont::Bold)),
7514 mLabelColor(Qt::black),
7515 mSelectedLabelColor(Qt::blue),
7519 mSelectedTickLabelFont(QFont(mTickLabelFont.family(), mTickLabelFont.pointSize(), QFont::Bold)),
7520 mTickLabelColor(Qt::black),
7521 mSelectedTickLabelColor(Qt::blue),
7522 mNumberPrecision(6),
7523 mNumberFormatChar(
'g'),
7524 mNumberBeautifulPowers(true),
7528 mTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
7529 mSelectedTickPen(QPen(Qt::blue, 2)),
7530 mSubTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
7531 mSelectedSubTickPen(QPen(Qt::blue, 2)),
7534 mRangeReversed(false),
7535 mScaleType(stLinear),
7540 mCachedMarginValid(false),
7560 }
else if (type ==
atLeft)
7598 result.append(QLatin1Char(
'b'));
7600 result.append(QLatin1Char(
'c'));
7786 if (alignment == Qt::AlignLeft)
7788 else if (alignment == Qt::AlignRight)
7791 setRange(position-size/2.0, position+size/2.0);
7870 qDebug() << Q_FUNC_INFO <<
"can not set 0 as axis ticker";
8005 if (formatCode.isEmpty())
8007 qDebug() << Q_FUNC_INFO <<
"Passed formatCode is empty";
8013 QString allowedFormatChars(QLatin1String(
"eEfgG"));
8014 if (allowedFormatChars.contains(formatCode.at(0)))
8019 qDebug() << Q_FUNC_INFO <<
"Invalid number format code (first char not in 'eEfgG'):" << formatCode;
8022 if (formatCode.length() < 2)
8035 qDebug() << Q_FUNC_INFO <<
"Invalid number format code (second char not 'b' or first char neither 'e' nor 'g'):" << formatCode;
8038 if (formatCode.length() < 3)
8045 if (formatCode.at(2) == QLatin1Char(
'c'))
8048 }
else if (formatCode.at(2) == QLatin1Char(
'd'))
8053 qDebug() << Q_FUNC_INFO <<
"Invalid number format code (third char neither 'c' nor 'd'):" << formatCode;
8463 qDebug() << Q_FUNC_INFO <<
"Center of scaling operation doesn't lie in same logarithmic sign domain as range:" << center;
8484 int otherPixelSize, ownPixelSize;
8496 double newRangeSize = ratio*otherAxis->
range().
size()*ownPixelSize/(double)otherPixelSize;
8508 QList<QCPAbstractPlottable*> p =
plottables();
8510 bool haveRange =
false;
8511 for (
int i=0; i<p.size(); ++i)
8513 if (!p.at(i)->realVisibility() && onlyVisiblePlottables)
8516 bool currentFoundRange;
8520 if (p.at(i)->keyAxis() ==
this)
8521 plottableRange = p.at(i)->getKeyRange(currentFoundRange, signDomain);
8523 plottableRange = p.at(i)->getValueRange(currentFoundRange, signDomain);
8524 if (currentFoundRange)
8527 newRange = plottableRange;
8529 newRange.
expand(plottableRange);
8537 double center = (newRange.
lower+newRange.
upper)*0.5;
8607 else if (value <= 0.0 && mRange.upper >= 0.0)
8629 else if (value <= 0.0 && mRange.upper >= 0.0)
8675 details->setValue(part);
8688 QList<QCPAbstractPlottable*> result;
8706 QList<QCPGraph*> result;
8725 QList<QCPAbstractItem*> result;
8730 QList<QCPItemPosition*> positions =
mParentPlot->
mItems.at(itemId)->positions();
8731 for (
int posId=0; posId<positions.size(); ++posId)
8733 if (positions.at(posId)->keyAxis() ==
this || positions.at(posId)->valueAxis() ==
this)
8757 qDebug() << Q_FUNC_INFO <<
"Invalid margin side passed:" << (int)side;
8772 default: qDebug() << Q_FUNC_INFO <<
"invalid axis type";
return atLeft;
break;
8785 if (selectionStateChanged)
8795 if (selectionStateChanged)
8825 if (event->buttons() & Qt::LeftButton)
8856 const double startPixel =
orientation() == Qt::Horizontal ? startPos.x() : startPos.y();
8857 const double currentPixel =
orientation() == Qt::Horizontal ?
event->pos().x() :
event->pos().y();
8924 const double wheelSteps =
event->delta()/120.0;
8958 QVector<double> subTickPositions;
8959 QVector<double> tickPositions;
8977 for (
int i=0; i<subTickCount; ++i)
9117 QVector<double> tickPositions;
9178 basePen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
9185 substituteExponent(true),
9186 numberMultiplyCross(false),
9191 tickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
9192 subTickPen(QPen(Qt::black, 0, Qt::SolidLine, Qt::SquareCap)),
9194 abbreviateDecimalPowers(false),
9195 reversedEndings(false),
9230 double xCor = 0, yCor = 0;
9242 baseLine.setPoints(origin+QPointF(xCor, yCor), origin+QPointF(
axisRect.width()+xCor, yCor));
9244 baseLine.setPoints(origin+QPointF(xCor, yCor), origin+QPointF(xCor, -
axisRect.height()+yCor));
9246 baseLine = QLineF(baseLine.p2(), baseLine.p1());
9286 painter->setBrush(QBrush(
basePen.color()));
9287 QCPVector2D baseLineVector(baseLine.dx(), baseLine.dy());
9298 oldClipRect = painter->clipRegion().boundingRect();
9301 QSize tickLabelsSize(0, 0);
9309 int distanceToAxis = margin;
9312 for (
int i=0; i<maxLabelIndex; ++i)
9318 painter->setClipRect(oldClipRect);
9322 if (!
label.isEmpty())
9327 labelBounds = painter->fontMetrics().boundingRect(0, 0, 0, 0, Qt::TextDontClip,
label);
9330 QTransform oldTransform = painter->transform();
9331 painter->translate((origin.x()-margin-labelBounds.height()), origin.y());
9332 painter->rotate(-90);
9333 painter->drawText(0, 0,
axisRect.height(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter,
label);
9334 painter->setTransform(oldTransform);
9338 QTransform oldTransform = painter->transform();
9339 painter->translate((origin.x()+margin+labelBounds.height()), origin.y()-
axisRect.height());
9340 painter->rotate(90);
9341 painter->drawText(0, 0,
axisRect.height(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter,
label);
9342 painter->setTransform(oldTransform);
9345 painter->drawText(origin.x(), origin.y()-margin-labelBounds.height(),
axisRect.width(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter,
label);
9347 painter->drawText(origin.x(), origin.y()+margin,
axisRect.width(), labelBounds.height(), Qt::TextDontClip | Qt::AlignCenter,
label);
9351 int selectionTolerance = 0;
9355 qDebug() << Q_FUNC_INFO <<
"mParentPlot is null";
9357 int selAxisInSize = selectionTolerance;
9358 int selTickLabelSize;
9359 int selTickLabelOffset;
9362 selTickLabelSize = (
QCPAxis::orientation(
type) == Qt::Horizontal ? tickLabelsSize.height() : tickLabelsSize.width());
9366 selTickLabelSize = -(
QCPAxis::orientation(
type) == Qt::Horizontal ? tickLabelsSize.height() : tickLabelsSize.width());
9369 int selLabelSize = labelBounds.height();
9416 QSize tickLabelsSize(0, 0);
9427 if (!
label.isEmpty())
9431 bounds = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip | Qt::AlignHCenter | Qt::AlignVCenter,
label);
9491 if (text.isEmpty())
return;
9493 QPointF labelAnchor;
9512 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 9513 # ifdef QCP_DEVICEPIXELRATIO_FLOAT 9521 cachedLabel->
pixmap.fill(Qt::transparent);
9523 cachePainter.
setPen(painter->pen());
9527 bool labelClippedByBorder =
false;
9535 if (!labelClippedByBorder)
9537 painter->drawPixmap(labelAnchor+cachedLabel->
offset, cachedLabel->
pixmap);
9546 bool labelClippedByBorder =
false;
9554 if (!labelClippedByBorder)
9556 drawTickLabel(painter, finalPosition.x(), finalPosition.y(), labelData);
9562 if (finalSize.width() > tickLabelsSize->width())
9563 tickLabelsSize->setWidth(finalSize.width());
9564 if (finalSize.height() > tickLabelsSize->height())
9565 tickLabelsSize->setHeight(finalSize.height());
9580 QTransform oldTransform = painter->transform();
9581 QFont oldFont = painter->font();
9584 painter->translate(x, y);
9589 if (!labelData.
expPart.isEmpty())
9591 painter->setFont(labelData.
baseFont);
9592 painter->drawText(0, 0, 0, 0, Qt::TextDontClip, labelData.
basePart);
9595 painter->setFont(labelData.
expFont);
9599 painter->setFont(labelData.
baseFont);
9604 painter->setTransform(oldTransform);
9605 painter->setFont(oldFont);
9621 bool useBeautifulPowers =
false;
9626 ePos = text.indexOf(QLatin1Char(
'e'));
9627 if (ePos > 0 && text.at(ePos-1).isDigit())
9630 while (eLast+1 < text.size() && (text.at(eLast+1) == QLatin1Char(
'+') || text.at(eLast+1) == QLatin1Char(
'-') || text.at(eLast+1).isDigit()))
9633 useBeautifulPowers =
true;
9639 if (result.
baseFont.pointSizeF() > 0)
9641 if (useBeautifulPowers)
9648 result.
basePart = QLatin1String(
"10");
9651 result.
expPart = text.mid(ePos+1, eLast-ePos);
9653 while (result.
expPart.length() > 2 && result.
expPart.at(1) == QLatin1Char(
'0'))
9655 if (!result.
expPart.isEmpty() && result.
expPart.at(0) == QLatin1Char(
'+'))
9659 if (result.
expFont.pointSize() > 0)
9672 result.
totalBounds = QFontMetrics(result.
baseFont).boundingRect(0, 0, 0, 0, Qt::TextDontClip | Qt::AlignHCenter, result.
basePart);
9680 QTransform transform;
9738 x = +qSin(radians)*labelData.
totalBounds.height();
9760 x = -qSin(-radians)*labelData.
totalBounds.height()/2.0;
9761 y = -qCos(-radians)*labelData.
totalBounds.height();
9774 x = +qSin(radians)*labelData.
totalBounds.height()/2.0;
9779 y = +qSin(-radians)*labelData.
totalBounds.width();
9788 return QPointF(x, y);
9813 if (finalSize.width() > tickLabelsSize->width())
9814 tickLabelsSize->setWidth(finalSize.width());
9815 if (finalSize.height() > tickLabelsSize->height())
9816 tickLabelsSize->setHeight(finalSize.height());
9913 mBrush(Qt::NoBrush),
10022 if (properties.testFlag(
spPen))
10028 if (properties.testFlag(
spBrush))
10030 if (properties.testFlag(
spSize))
10032 if (properties.testFlag(
spShape))
10138 painter->setBrush(
mBrush);
10159 double w =
mSize/2.0;
10165 painter->
drawLine(QPointF(x, y), QPointF(x+0.0001, y));
10170 painter->
drawLine(QLineF(x-w, y-w, x+w, y+w));
10171 painter->
drawLine(QLineF(x-w, y+w, x+w, y-w));
10176 painter->
drawLine(QLineF(x-w, y, x+w, y));
10177 painter->
drawLine(QLineF( x, y+w, x, y-w));
10182 painter->drawEllipse(QPointF(x , y), w, w);
10187 QBrush b = painter->brush();
10188 painter->setBrush(painter->pen().color());
10189 painter->drawEllipse(QPointF(x , y), w, w);
10190 painter->setBrush(b);
10195 painter->drawRect(QRectF(x-w, y-w,
mSize,
mSize));
10200 QPointF lineArray[4] = {QPointF(x-w, y),
10204 painter->drawPolygon(lineArray, 4);
10209 painter->
drawLine(QLineF(x-w, y, x+w, y));
10210 painter->
drawLine(QLineF( x, y+w, x, y-w));
10211 painter->
drawLine(QLineF(x-w*0.707, y-w*0.707, x+w*0.707, y+w*0.707));
10212 painter->
drawLine(QLineF(x-w*0.707, y+w*0.707, x+w*0.707, y-w*0.707));
10217 QPointF lineArray[3] = {QPointF(x-w, y+0.755*w),
10218 QPointF(x+w, y+0.755*w),
10219 QPointF( x, y-0.977*w)};
10220 painter->drawPolygon(lineArray, 3);
10225 QPointF lineArray[3] = {QPointF(x-w, y-0.755*w),
10226 QPointF(x+w, y-0.755*w),
10227 QPointF( x, y+0.977*w)};
10228 painter->drawPolygon(lineArray, 3);
10233 painter->drawRect(QRectF(x-w, y-w,
mSize,
mSize));
10234 painter->
drawLine(QLineF(x-w, y-w, x+w*0.95, y+w*0.95));
10235 painter->
drawLine(QLineF(x-w, y+w*0.95, x+w*0.95, y-w));
10240 painter->drawRect(QRectF(x-w, y-w,
mSize,
mSize));
10241 painter->
drawLine(QLineF(x-w, y, x+w*0.95, y));
10242 painter->
drawLine(QLineF( x, y+w, x, y-w));
10247 painter->drawEllipse(QPointF(x, y), w, w);
10248 painter->
drawLine(QLineF(x-w*0.707, y-w*0.707, x+w*0.670, y+w*0.670));
10249 painter->
drawLine(QLineF(x-w*0.707, y+w*0.670, x+w*0.670, y-w*0.707));
10254 painter->drawEllipse(QPointF(x, y), w, w);
10255 painter->
drawLine(QLineF(x-w, y, x+w, y));
10256 painter->
drawLine(QLineF( x, y+w, x, y-w));
10261 painter->drawEllipse(QPointF(x, y), w, w);
10262 painter->
drawLine(QLineF(x, y-w, x, y+w));
10263 painter->
drawLine(QLineF(x, y, x-w*0.707, y+w*0.707));
10264 painter->
drawLine(QLineF(x, y, x+w*0.707, y+w*0.707));
10269 const double widthHalf =
mPixmap.width()*0.5;
10270 const double heightHalf =
mPixmap.height()*0.5;
10271 #if QT_VERSION < QT_VERSION_CHECK(4, 8, 0) 10272 const QRectF clipRect = painter->clipRegion().boundingRect().adjusted(-widthHalf, -heightHalf, widthHalf, heightHalf);
10274 const QRectF clipRect = painter->clipBoundingRect().adjusted(-widthHalf, -heightHalf, widthHalf, heightHalf);
10276 if (clipRect.contains(x, y))
10277 painter->drawPixmap(x-widthHalf, y-heightHalf,
mPixmap);
10282 QTransform oldTransform = painter->transform();
10283 painter->translate(x, y);
10286 painter->setTransform(oldTransform);
10332 mPen(QColor(80, 80, 255), 2.5),
10402 painter->setBrush(
mBrush);
10449 Q_UNUSED(selection)
10469 qDebug() << Q_FUNC_INFO <<
"This selection decorator is already registered with plottable:" <<
reinterpret_cast<quintptr
>(
mPlottable);
10691 QCPLayerable(keyAxis->parentPlot(), QString(), keyAxis->axisRect()),
10693 mAntialiasedFill(true),
10694 mAntialiasedScatters(true),
10698 mValueAxis(valueAxis),
10700 mSelectionDecorator(0)
10703 qDebug() << Q_FUNC_INFO <<
"Parent plot of keyAxis is not the same as that of valueAxis.";
10705 qDebug() << Q_FUNC_INFO <<
"keyAxis and valueAxis must be orthogonal to each other.";
10906 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
10927 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QPointF(); }
10948 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
10997 if (!keyAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key axis";
return; }
11011 double center = (newRange.
lower+newRange.
upper)*0.5;
11040 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
11054 double center = (newRange.
lower+newRange.
upper)*0.5;
11087 qDebug() << Q_FUNC_INFO <<
"passed legend is null";
11092 qDebug() << Q_FUNC_INFO <<
"passed legend isn't in the same QCustomPlot as this plottable";
11132 qDebug() << Q_FUNC_INFO <<
"passed legend is null";
11249 if (selectionStateChanged)
11250 *selectionStateChanged =
mSelection != selectionBefore;
11261 if (selectionStateChanged)
11262 *selectionStateChanged =
mSelection != selectionBefore;
11318 mParentItem(parentItem),
11319 mAnchorId(anchorId)
11353 qDebug() << Q_FUNC_INFO <<
"no valid anchor id set:" <<
mAnchorId;
11358 qDebug() << Q_FUNC_INFO <<
"no parent item set";
11376 qDebug() << Q_FUNC_INFO <<
"provided pos is child already" <<
reinterpret_cast<quintptr
>(pos);
11388 qDebug() << Q_FUNC_INFO <<
"provided pos isn't child" <<
reinterpret_cast<quintptr
>(pos);
11404 qDebug() << Q_FUNC_INFO <<
"provided pos is child already" <<
reinterpret_cast<quintptr
>(pos);
11416 qDebug() << Q_FUNC_INFO <<
"provided pos isn't child" <<
reinterpret_cast<quintptr
>(pos);
11490 mPositionTypeX(ptAbsolute),
11491 mPositionTypeY(ptAbsolute),
11571 bool retainPixelPosition =
true;
11573 retainPixelPosition =
false;
11575 retainPixelPosition =
false;
11578 if (retainPixelPosition)
11583 if (retainPixelPosition)
11601 bool retainPixelPosition =
true;
11603 retainPixelPosition =
false;
11605 retainPixelPosition =
false;
11608 if (retainPixelPosition)
11613 if (retainPixelPosition)
11640 return successX && successY;
11653 if (parentAnchor ==
this)
11655 qDebug() << Q_FUNC_INFO <<
"can't set self as parent anchor" <<
reinterpret_cast<quintptr
>(
parentAnchor);
11660 while (currentParent)
11665 if (currentParentPos ==
this)
11667 qDebug() << Q_FUNC_INFO <<
"can't create recursive parent-child-relationship" <<
reinterpret_cast<quintptr
>(
parentAnchor);
11670 currentParent = currentParentPos->parentAnchorX();
11678 qDebug() << Q_FUNC_INFO <<
"can't set parent to be an anchor which itself depends on this position" <<
reinterpret_cast<quintptr
>(
parentAnchor);
11691 if (keepPixelPosition)
11701 if (keepPixelPosition)
11718 if (parentAnchor ==
this)
11720 qDebug() << Q_FUNC_INFO <<
"can't set self as parent anchor" <<
reinterpret_cast<quintptr
>(
parentAnchor);
11725 while (currentParent)
11730 if (currentParentPos ==
this)
11732 qDebug() << Q_FUNC_INFO <<
"can't create recursive parent-child-relationship" <<
reinterpret_cast<quintptr
>(
parentAnchor);
11735 currentParent = currentParentPos->parentAnchorY();
11743 qDebug() << Q_FUNC_INFO <<
"can't set parent to be an anchor which itself depends on this position" <<
reinterpret_cast<quintptr
>(
parentAnchor);
11756 if (keepPixelPosition)
11766 if (keepPixelPosition)
11821 result.rx() =
mKey;
11843 result.rx() +=
mAxisRect.data()->left();
11845 qDebug() << Q_FUNC_INFO <<
"Item position type x is ptAxisRectRatio, but no axis rect was defined";
11855 qDebug() << Q_FUNC_INFO <<
"Item position type x is ptPlotCoords, but no axes were defined";
11887 result.ry() +=
mAxisRect.data()->top();
11889 qDebug() << Q_FUNC_INFO <<
"Item position type y is ptAxisRectRatio, but no axis rect was defined";
11899 qDebug() << Q_FUNC_INFO <<
"Item position type y is ptPlotCoords, but no axes were defined";
11940 double x = pixelPosition.x();
11941 double y = pixelPosition.y();
11968 x /= (double)
mAxisRect.data()->width();
11970 qDebug() << Q_FUNC_INFO <<
"Item position type x is ptAxisRectRatio, but no axis rect was defined";
11976 x =
mKeyAxis.data()->pixelToCoord(x);
11980 qDebug() << Q_FUNC_INFO <<
"Item position type x is ptPlotCoords, but no axes were defined";
12010 y /= (double)
mAxisRect.data()->height();
12012 qDebug() << Q_FUNC_INFO <<
"Item position type y is ptAxisRectRatio, but no axis rect was defined";
12018 x =
mKeyAxis.data()->pixelToCoord(y);
12022 qDebug() << Q_FUNC_INFO <<
"Item position type y is ptPlotCoords, but no axes were defined";
12205 mClipToAxisRect(false),
12211 QList<QCPAxisRect*> rects = parentPlot->
axisRects();
12212 if (rects.size() > 0)
12315 qDebug() << Q_FUNC_INFO <<
"position with name not found:" << name;
12331 for (
int i=0; i<
mAnchors.size(); ++i)
12333 if (
mAnchors.at(i)->name() == name)
12336 qDebug() << Q_FUNC_INFO <<
"anchor with name not found:" << name;
12350 for (
int i=0; i<
mAnchors.size(); ++i)
12352 if (
mAnchors.at(i)->name() == name)
12408 double result = -1;
12411 QList<QLineF> lines;
12412 lines << QLineF(rect.topLeft(), rect.topRight()) << QLineF(rect.bottomLeft(), rect.bottomRight())
12413 << QLineF(rect.topLeft(), rect.bottomLeft()) << QLineF(rect.topRight(), rect.bottomRight());
12414 double minDistSqr = std::numeric_limits<double>::max();
12415 for (
int i=0; i<lines.size(); ++i)
12418 if (distSqr < minDistSqr)
12419 minDistSqr = distSqr;
12421 result = qSqrt(minDistSqr);
12426 if (rect.contains(pos))
12444 qDebug() << Q_FUNC_INFO <<
"called on item which shouldn't have any anchors (this method not reimplemented). anchorId" << anchorId;
12465 qDebug() << Q_FUNC_INFO <<
"anchor/position with name exists already:" << name;
12474 return newPosition;
12499 qDebug() << Q_FUNC_INFO <<
"anchor/position with name exists already:" << name;
12514 if (selectionStateChanged)
12515 *selectionStateChanged =
mSelected != selBefore;
12526 if (selectionStateChanged)
12527 *selectionStateChanged =
mSelected != selBefore;
12855 mBufferDevicePixelRatio(1.0),
12857 mAutoAddPlottableToLegend(true),
12861 mSelectionTolerance(8),
12862 mNoAntialiasingOnDrag(false),
12863 mBackgroundBrush(Qt::white, Qt::SolidPattern),
12864 mBackgroundScaled(true),
12865 mBackgroundScaledMode(Qt::KeepAspectRatioByExpanding),
12868 mMultiSelectModifier(Qt::ControlModifier),
12872 mMouseHasMoved(false),
12873 mMouseEventLayerable(0),
12874 mMouseSignalLayerable(0),
12875 mReplotting(false),
12876 mReplotQueued(false),
12877 mOpenGlMultisamples(16),
12878 mOpenGlAntialiasedElementsBackup(
QCP::
aeNone),
12879 mOpenGlCacheLabelsBackup(true)
12881 setAttribute(Qt::WA_NoMousePropagation);
12882 setAttribute(Qt::WA_OpaquePaintEvent);
12883 setFocusPolicy(Qt::ClickFocus);
12884 setMouseTracking(
true);
12885 QLocale currentLocale = locale();
12886 currentLocale.setNumberOptions(QLocale::OmitGroupSeparator);
12887 setLocale(currentLocale);
12888 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 12889 # ifdef QCP_DEVICEPIXELRATIO_FLOAT 12925 defaultAxisRect->
setLayer(QLatin1String(
"background"));
13320 #ifdef QCUSTOMPLOT_USE_OPENGL 13334 qDebug() << Q_FUNC_INFO <<
"Failed to enable OpenGL, continuing plotting without hardware acceleration.";
13351 qDebug() << Q_FUNC_INFO <<
"QCustomPlot can't use OpenGL because QCUSTOMPLOT_USE_OPENGL was not defined during compilation (add 'DEFINES += QCUSTOMPLOT_USE_OPENGL' to your qmake .pro file)";
13393 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 13399 qDebug() << Q_FUNC_INFO <<
"Device pixel ratios not supported for Qt versions before 5.4";
13500 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
13533 qDebug() << Q_FUNC_INFO <<
"plottable not in list:" <<
reinterpret_cast<quintptr
>(
plottable);
13558 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
13574 for (
int i=c-1; i >= 0; --i)
13598 QList<QCPAbstractPlottable*> result;
13602 result.append(plottable);
13626 if (onlySelectable && !plottable->
selectable())
13630 double currentDistance = plottable->
selectTest(pos,
false);
13631 if (currentDistance >= 0 && currentDistance < resultDistance)
13634 resultDistance = currentDistance;
13639 return resultPlottable;
13660 if (index >= 0 && index <
mGraphs.size())
13665 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
13700 if (!keyAxis) keyAxis =
xAxis;
13701 if (!valueAxis) valueAxis =
yAxis;
13702 if (!keyAxis || !valueAxis)
13704 qDebug() << Q_FUNC_INFO <<
"can't use default QCustomPlot xAxis or yAxis, because at least one is invalid (has been deleted)";
13709 qDebug() << Q_FUNC_INFO <<
"passed keyAxis or valueAxis doesn't have this QCustomPlot as parent";
13714 newGraph->
setName(QLatin1String(
"Graph ")+QString::number(
mGraphs.size()));
13739 if (index >= 0 && index <
mGraphs.size())
13756 for (
int i=c-1; i >= 0; --i)
13781 QList<QCPGraph*> result;
13785 result.append(graph);
13800 if (index >= 0 && index <
mItems.size())
13802 return mItems.at(index);
13805 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
13835 if (
mItems.contains(item))
13842 qDebug() << Q_FUNC_INFO <<
"item not in list:" <<
reinterpret_cast<quintptr
>(
item);
13853 if (index >= 0 && index <
mItems.size())
13857 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
13872 for (
int i=c-1; i >= 0; --i)
13894 QList<QCPAbstractItem*> result;
13898 result.append(item);
13927 double currentDistance = item->
selectTest(pos,
false);
13928 if (currentDistance >= 0 && currentDistance < resultDistance)
13931 resultDistance = currentDistance;
13946 return mItems.contains(item);
13961 if (layer->
name() == name)
13975 if (index >= 0 && index <
mLayers.size())
13980 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
14010 qDebug() << Q_FUNC_INFO <<
"layer with name doesn't exist:" << name;
14025 if (!
mLayers.contains(layer))
14027 qDebug() << Q_FUNC_INFO <<
"layer not a layer of this QCustomPlot:" <<
reinterpret_cast<quintptr
>(
layer);
14062 if (!
mLayers.contains(otherLayer))
14064 qDebug() << Q_FUNC_INFO <<
"otherLayer not a layer of this QCustomPlot:" <<
reinterpret_cast<quintptr
>(otherLayer);
14069 qDebug() << Q_FUNC_INFO <<
"A layer exists already with the name" << name;
14096 if (!
mLayers.contains(layer))
14098 qDebug() << Q_FUNC_INFO <<
"layer not a layer of this QCustomPlot:" <<
reinterpret_cast<quintptr
>(
layer);
14103 qDebug() << Q_FUNC_INFO <<
"can't remove last layer";
14108 int removedIndex = layer->
index();
14109 bool isFirstLayer = removedIndex==0;
14111 QList<QCPLayerable*> children = layer->
children();
14114 for (
int i=children.size()-1; i>=0; --i)
14115 children.at(i)->moveToLayer(targetLayer,
true);
14118 for (
int i=0; i<children.size(); ++i)
14119 children.at(i)->moveToLayer(targetLayer,
false);
14145 if (!
mLayers.contains(layer))
14147 qDebug() << Q_FUNC_INFO <<
"layer not a layer of this QCustomPlot:" <<
reinterpret_cast<quintptr
>(
layer);
14150 if (!
mLayers.contains(otherLayer))
14152 qDebug() << Q_FUNC_INFO <<
"otherLayer not a layer of this QCustomPlot:" <<
reinterpret_cast<quintptr
>(otherLayer);
14158 else if (layer->
index() < otherLayer->
index())
14196 const QList<QCPAxisRect*> rectList =
axisRects();
14197 if (index >= 0 && index < rectList.size())
14199 return rectList.at(index);
14202 qDebug() << Q_FUNC_INFO <<
"invalid axis rect index" << index;
14214 QList<QCPAxisRect*> result;
14215 QStack<QCPLayoutElement*> elementStack;
14219 while (!elementStack.isEmpty())
14225 elementStack.push(element);
14226 if (
QCPAxisRect *ar = qobject_cast<QCPAxisRect*>(element))
14247 bool searchSubElements =
true;
14248 while (searchSubElements && currentElement)
14250 searchSubElements =
false;
14255 currentElement = subElement;
14256 searchSubElements =
true;
14261 return currentElement;
14278 bool searchSubElements =
true;
14279 while (searchSubElements && currentElement)
14281 searchSubElements =
false;
14286 currentElement = subElement;
14287 searchSubElements =
true;
14288 if (
QCPAxisRect *ar = qobject_cast<QCPAxisRect*>(currentElement))
14306 QList<QCPAxis*> result, allAxes;
14308 allAxes << rect->
axes();
14310 foreach (
QCPAxis *axis, allAxes)
14313 result.append(axis);
14328 QList<QCPLegend*> result;
14330 QStack<QCPLayoutElement*> elementStack;
14334 while (!elementStack.isEmpty())
14340 elementStack.push(subElement);
14341 if (
QCPLegend *leg = qobject_cast<QCPLegend*>(subElement))
14344 result.append(leg);
14403 QTimer::singleShot(0,
this, SLOT(
replot()));
14441 QList<QCPAxis*> allAxes;
14443 allAxes << rect->
axes();
14445 foreach (
QCPAxis *axis, allAxes)
14446 axis->
rescale(onlyVisiblePlottables);
14488 bool success =
false;
14489 #ifdef QT_NO_PRINTER 14491 Q_UNUSED(exportPen)
14494 Q_UNUSED(pdfCreator)
14496 qDebug() << Q_FUNC_INFO <<
"Qt was built without printer support (QT_NO_PRINTER). PDF not created.";
14498 int newWidth, newHeight;
14499 if (width == 0 || height == 0)
14501 newWidth = this->width();
14502 newHeight = this->height();
14506 newHeight = height;
14509 QPrinter printer(QPrinter::ScreenResolution);
14510 printer.setOutputFileName(fileName);
14511 printer.setOutputFormat(QPrinter::PdfFormat);
14512 printer.setColorMode(QPrinter::Color);
14513 printer.printEngine()->setProperty(QPrintEngine::PPK_Creator, pdfCreator);
14514 printer.printEngine()->setProperty(QPrintEngine::PPK_DocumentName, pdfTitle);
14517 #if QT_VERSION < QT_VERSION_CHECK(5, 3, 0) 14518 printer.setFullPage(
true);
14519 printer.setPaperSize(
viewport().size(), QPrinter::DevicePixel);
14521 QPageLayout pageLayout;
14522 pageLayout.setMode(QPageLayout::FullPageMode);
14523 pageLayout.setOrientation(QPageLayout::Portrait);
14524 pageLayout.setMargins(QMarginsF(0, 0, 0, 0));
14525 pageLayout.setPageSize(QPageSize(
viewport().size(), QPageSize::Point, QString(), QPageSize::ExactMatch));
14526 printer.setPageLayout(pageLayout);
14529 if (printpainter.
begin(&printer))
14540 draw(&printpainter);
14541 printpainter.end();
14545 #endif // QT_NO_PRINTER 14596 return saveRastered(fileName, width, height, scale,
"PNG", quality, resolution, resolutionUnit);
14643 return saveRastered(fileName, width, height, scale,
"JPG", quality, resolution, resolutionUnit);
14687 return saveRastered(fileName, width, height, scale,
"BMP", -1, resolution, resolutionUnit);
14722 if (painter.isActive())
14724 painter.setRenderHint(QPainter::HighQualityAntialiasing);
14728 for (
int bufferIndex = 0; bufferIndex <
mPaintBuffers.size(); ++bufferIndex)
14762 QList<QVariant> details;
14764 for (
int i=0; i<candidates.size(); ++i)
14767 candidates.at(i)->mouseDoubleClickEvent(event, details.at(i));
14768 if (event->isAccepted())
14777 if (!candidates.isEmpty())
14783 dataIndex = details.first().value<
QCPDataSelection>().dataRange().begin();
14785 }
else if (
QCPAxis *ax = qobject_cast<QCPAxis*>(candidates.first()))
14787 else if (
QCPAbstractItem *ai = qobject_cast<QCPAbstractItem*>(candidates.first()))
14789 else if (
QCPLegend *lg = qobject_cast<QCPLegend*>(candidates.first()))
14821 QList<QVariant> details;
14823 if (!candidates.isEmpty())
14829 for (
int i=0; i<candidates.size(); ++i)
14832 candidates.at(i)->mousePressEvent(event, details.at(i));
14833 if (event->isAccepted())
14894 if (event->button() == Qt::LeftButton)
14944 QList<QCPLayerable*> candidates =
layerableListAt(event->pos(),
false);
14945 for (
int i=0; i<candidates.size(); ++i)
14948 candidates.at(i)->wheelEvent(event);
14949 if (event->isAccepted())
14974 layer->
draw(painter);
15064 int bufferIndex = 0;
15068 for (
int layerIndex = 0; layerIndex <
mLayers.size(); ++layerIndex)
15112 #if defined(QCP_OPENGL_FBO) 15114 #elif defined(QCP_OPENGL_PBUFFER) 15117 qDebug() << Q_FUNC_INFO <<
"OpenGL enabled even though no support for it compiled in, this shouldn't have happened. Falling back to pixmap paint buffer.";
15160 #ifdef QCP_OPENGL_FBO 15162 QSurfaceFormat proposedSurfaceFormat;
15164 #ifdef QCP_OPENGL_OFFSCREENSURFACE 15165 QOffscreenSurface *surface =
new QOffscreenSurface;
15167 QWindow *surface =
new QWindow;
15168 surface->setSurfaceType(QSurface::OpenGLSurface);
15170 surface->setFormat(proposedSurfaceFormat);
15172 mGlSurface = QSharedPointer<QSurface>(surface);
15173 mGlContext = QSharedPointer<QOpenGLContext>(
new QOpenGLContext);
15174 mGlContext->setFormat(mGlSurface->format());
15175 if (!mGlContext->create())
15177 qDebug() << Q_FUNC_INFO <<
"Failed to create OpenGL context";
15178 mGlContext.clear();
15179 mGlSurface.clear();
15182 if (!mGlContext->makeCurrent(mGlSurface.data()))
15184 qDebug() << Q_FUNC_INFO <<
"Failed to make opengl context current";
15185 mGlContext.clear();
15186 mGlSurface.clear();
15189 if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
15191 qDebug() << Q_FUNC_INFO <<
"OpenGL of this system doesn't support frame buffer objects";
15192 mGlContext.clear();
15193 mGlSurface.clear();
15196 mGlPaintDevice = QSharedPointer<QOpenGLPaintDevice>(
new QOpenGLPaintDevice);
15198 #elif defined(QCP_OPENGL_PBUFFER) 15199 return QGLFormat::hasOpenGL();
15218 #ifdef QCP_OPENGL_FBO 15219 mGlPaintDevice.clear();
15220 mGlContext.clear();
15221 mGlSurface.clear();
15251 if (this->legend == legend)
15274 bool selectionStateChanged =
false;
15278 QMap<int, QPair<QCPAbstractPlottable*, QCPDataSelection> > potentialSelections;
15279 QRectF rectF(rect.normalized());
15287 QCPDataSelection dataSel = plottableInterface->selectTestRect(rectF,
true);
15289 potentialSelections.insertMulti(dataSel.
dataPointCount(), QPair<QCPAbstractPlottable*, QCPDataSelection>(
plottable, dataSel));
15296 if (!potentialSelections.isEmpty())
15298 QMap<int, QPair<QCPAbstractPlottable*, QCPDataSelection> >::iterator it = potentialSelections.begin();
15299 while (it != potentialSelections.end()-1)
15300 it = potentialSelections.erase(it);
15313 if ((potentialSelections.isEmpty() || potentialSelections.constBegin()->first != layerable) &&
mInteractions.testFlag(layerable->
selectionCategory()))
15315 bool selChanged =
false;
15317 selectionStateChanged |= selChanged;
15324 QMap<int, QPair<QCPAbstractPlottable*, QCPDataSelection> >::const_iterator it = potentialSelections.constEnd();
15325 while (it != potentialSelections.constBegin())
15328 if (
mInteractions.testFlag(it.value().first->selectionCategory()))
15330 bool selChanged =
false;
15331 it.value().first->selectEvent(event, additive, QVariant::fromValue(it.value().second), &selChanged);
15332 selectionStateChanged |= selChanged;
15338 if (selectionStateChanged)
15363 affectedAxes.removeAll(static_cast<QCPAxis*>(0));
15390 bool selectionStateChanged =
false;
15401 bool selChanged =
false;
15403 selectionStateChanged |= selChanged;
15411 bool selChanged =
false;
15412 clickedLayerable->
selectEvent(event, additive, details, &selChanged);
15413 selectionStateChanged |= selChanged;
15415 if (selectionStateChanged)
15437 qDebug() << Q_FUNC_INFO <<
"plottable already added to this QCustomPlot:" <<
reinterpret_cast<quintptr
>(
plottable);
15442 qDebug() << Q_FUNC_INFO <<
"plottable not created with this QCustomPlot as parent:" <<
reinterpret_cast<quintptr
>(
plottable);
15450 if (!plottable->
layer())
15468 qDebug() << Q_FUNC_INFO <<
"passed graph is zero";
15473 qDebug() << Q_FUNC_INFO <<
"graph already registered with this QCustomPlot";
15493 if (
mItems.contains(item))
15495 qDebug() << Q_FUNC_INFO <<
"item already added to this QCustomPlot:" <<
reinterpret_cast<quintptr
>(
item);
15500 qDebug() << Q_FUNC_INFO <<
"item not created with this QCustomPlot as parent:" <<
reinterpret_cast<quintptr
>(
item);
15505 if (!item->
layer())
15518 for (
int i=0; i<
mLayers.size(); ++i)
15539 QList<QVariant> details;
15540 QList<QCPLayerable*> candidates =
layerableListAt(pos, onlySelectable, selectionDetails ? &details : 0);
15541 if (selectionDetails && !details.isEmpty())
15542 *selectionDetails = details.first();
15543 if (!candidates.isEmpty())
15544 return candidates.first();
15569 QList<QCPLayerable*> result;
15570 for (
int layerIndex=
mLayers.size()-1; layerIndex>=0; --layerIndex)
15572 const QList<QCPLayerable*> layerables =
mLayers.at(layerIndex)->children();
15573 for (
int i=layerables.size()-1; i>=0; --i)
15575 if (!layerables.at(i)->realVisibility())
15578 double dist = layerables.at(i)->selectTest(pos, onlySelectable, selectionDetails ? &details : 0);
15581 result.append(layerables.at(i));
15582 if (selectionDetails)
15583 selectionDetails->append(details);
15610 QImage buffer =
toPixmap(width, height, scale).toImage();
15612 int dotsPerMeter = 0;
15613 switch (resolutionUnit)
15619 buffer.setDotsPerMeterX(dotsPerMeter);
15620 buffer.setDotsPerMeterY(dotsPerMeter);
15621 if (!buffer.isNull())
15622 return buffer.save(fileName, format, quality);
15638 int newWidth, newHeight;
15639 if (width == 0 || height == 0)
15641 newWidth = this->width();
15642 newHeight = this->height();
15646 newHeight = height;
15648 int scaledWidth = qRound(scale*newWidth);
15649 int scaledHeight = qRound(scale*newHeight);
15651 QPixmap result(scaledWidth, scaledHeight);
15654 painter.
begin(&result);
15655 if (painter.isActive())
15660 if (!qFuzzyCompare(scale, 1.0))
15664 painter.scale(scale, scale);
15673 qDebug() << Q_FUNC_INFO <<
"Couldn't activate painter on pixmap";
15694 int newWidth, newHeight;
15695 if (width == 0 || height == 0)
15697 newWidth = this->width();
15698 newHeight = this->height();
15702 newHeight = height;
15705 if (painter->isActive())
15715 qDebug() << Q_FUNC_INFO <<
"Passed painter is not active";
15765 mColorInterpolation(ciRGB),
15767 mColorBufferInvalidated(true)
15791 return ((other.
mLevelCount == this->mLevelCount) &&
15793 (other.
mPeriodic == this->mPeriodic) &&
15807 qDebug() << Q_FUNC_INFO <<
"n must be greater or equal 2 but was" << n;
15905 qDebug() << Q_FUNC_INFO <<
"null pointer given as data";
15910 qDebug() << Q_FUNC_INFO <<
"null pointer given as scanLine";
15921 for (
int i=0; i<n; ++i)
15923 int index = (int)((data[dataIndexFactor*i]-range.
lower)*posToIndexFactor) %
mLevelCount;
15930 for (
int i=0; i<n; ++i)
15932 int index = (data[dataIndexFactor*i]-range.
lower)*posToIndexFactor;
15944 for (
int i=0; i<n; ++i)
15953 for (
int i=0; i<n; ++i)
15979 qDebug() << Q_FUNC_INFO <<
"null pointer given as data";
15984 qDebug() << Q_FUNC_INFO <<
"null pointer given as alpha";
15989 qDebug() << Q_FUNC_INFO <<
"null pointer given as scanLine";
16000 for (
int i=0; i<n; ++i)
16002 int index = (int)((data[dataIndexFactor*i]-range.
lower)*posToIndexFactor) %
mLevelCount;
16005 if (alpha[dataIndexFactor*i] == 255)
16011 const float alphaF = alpha[dataIndexFactor*i]/255.0f;
16012 scanLine[i] = qRgba(qRed(rgb)*alphaF, qGreen(rgb)*alphaF, qBlue(rgb)*alphaF, qAlpha(rgb)*alphaF);
16017 for (
int i=0; i<n; ++i)
16019 int index = (data[dataIndexFactor*i]-range.
lower)*posToIndexFactor;
16024 if (alpha[dataIndexFactor*i] == 255)
16030 const float alphaF = alpha[dataIndexFactor*i]/255.0f;
16031 scanLine[i] = qRgba(qRed(rgb)*alphaF, qGreen(rgb)*alphaF, qBlue(rgb)*alphaF, qAlpha(rgb)*alphaF);
16039 for (
int i=0; i<n; ++i)
16044 if (alpha[dataIndexFactor*i] == 255)
16050 const float alphaF = alpha[dataIndexFactor*i]/255.0f;
16051 scanLine[i] = qRgba(qRed(rgb)*alphaF, qGreen(rgb)*alphaF, qBlue(rgb)*alphaF, qAlpha(rgb)*alphaF);
16056 for (
int i=0; i<n; ++i)
16063 if (alpha[dataIndexFactor*i] == 255)
16069 const float alphaF = alpha[dataIndexFactor*i]/255.0f;
16070 scanLine[i] = qRgba(qRed(rgb)*alphaF, qGreen(rgb)*alphaF, qBlue(rgb)*alphaF, qAlpha(rgb)*alphaF);
16246 for (QMap<double, QColor>::const_iterator it=
mColorStops.constBegin(); it!=
mColorStops.constEnd(); ++it)
16258 for (QMap<double, QColor>::const_iterator it=
mColorStops.constBegin(); it!=
mColorStops.constEnd(); ++it)
16260 if (it.value().alpha() < 255)
16277 double indexToPosFactor = 1.0/(double)(
mLevelCount-1);
16281 double position = i*indexToPosFactor;
16282 QMap<double, QColor>::const_iterator it =
mColorStops.lowerBound(position);
16291 QMap<double, QColor>::const_iterator high = it;
16292 QMap<double, QColor>::const_iterator low = it-1;
16293 double t = (position-low.key())/(high.key()-low.key());
16300 const int alpha = (1-t)*low.value().alpha() + t*high.value().alpha();
16301 const float alphaPremultiplier = alpha/255.0f;
16302 mColorBuffer[i] = qRgba(((1-t)*low.value().red() + t*high.value().red())*alphaPremultiplier,
16303 ((1-t)*low.value().green() + t*high.value().green())*alphaPremultiplier,
16304 ((1-t)*low.value().blue() + t*high.value().blue())*alphaPremultiplier,
16308 mColorBuffer[i] = qRgb(((1-t)*low.value().red() + t*high.value().red()),
16309 ((1-t)*low.value().green() + t*high.value().green()),
16310 ((1-t)*low.value().blue() + t*high.value().blue()));
16316 QColor lowHsv = low.value().toHsv();
16317 QColor highHsv = high.value().toHsv();
16319 double hueDiff = highHsv.hueF()-lowHsv.hueF();
16321 hue = lowHsv.hueF() - t*(1.0-hueDiff);
16322 else if (hueDiff < -0.5)
16323 hue = lowHsv.hueF() + t*(1.0+hueDiff);
16325 hue = lowHsv.hueF() + t*hueDiff;
16326 if (hue < 0) hue += 1.0;
16327 else if (hue >= 1.0) hue -= 1.0;
16330 const QRgb rgb = QColor::fromHsvF(hue,
16331 (1-t)*lowHsv.saturationF() + t*highHsv.saturationF(),
16332 (1-t)*lowHsv.valueF() + t*highHsv.valueF()).rgb();
16333 const float alpha = (1-t)*lowHsv.alphaF() + t*highHsv.alphaF();
16334 mColorBuffer[i] = qRgba(qRed(rgb)*alpha, qGreen(rgb)*alpha, qBlue(rgb)*alpha, 255*alpha);
16339 (1-t)*lowHsv.saturationF() + t*highHsv.saturationF(),
16340 (1-t)*lowHsv.valueF() + t*highHsv.valueF()).rgb();
16349 const QRgb rgb =
mColorStops.constBegin().value().rgb();
16350 const float alpha =
mColorStops.constBegin().value().alphaF();
16351 mColorBuffer.fill(qRgba(qRed(rgb)*alpha, qGreen(rgb)*alpha, qBlue(rgb)*alpha, 255*alpha));
16388 mBracketPen(QPen(Qt::black)),
16389 mBracketBrush(Qt::NoBrush),
16391 mBracketHeight(50),
16392 mBracketStyle(bsSquareBracket),
16393 mTangentToData(false),
16520 qDebug() << Q_FUNC_INFO <<
"unknown/custom bracket style can't be handeld by default implementation:" <<
static_cast<int>(
mBracketStyle);
16544 int closeBracketDir = -openBracketDir;
16547 double openBracketAngle = 0;
16548 double closeBracketAngle = 0;
16552 closeBracketAngle =
getTangentAngle(interface1d, dataRange.
end()-1, closeBracketDir);
16555 QTransform oldTransform = painter->transform();
16558 painter->translate(openBracketPos);
16559 painter->rotate(openBracketAngle/M_PI*180.0);
16561 painter->setTransform(oldTransform);
16565 painter->translate(closeBracketPos);
16566 painter->rotate(closeBracketAngle/M_PI*180.0);
16568 painter->setTransform(oldTransform);
16588 if (!interface1d || dataIndex < 0 || dataIndex >= interface1d->
dataCount())
16590 direction = direction < 0 ? -1 : 1;
16598 qDebug() << averageCount;
16600 QVector<QPointF> points(averageCount);
16601 QPointF pointsAverage;
16602 int currentIndex = dataIndex;
16603 for (
int i=0; i<averageCount; ++i)
16606 pointsAverage += points[i];
16607 currentIndex += direction;
16609 pointsAverage /= (double)averageCount;
16613 double denomSum = 0;
16614 for (
int i=0; i<averageCount; ++i)
16616 const double dx = points.at(i).x()-pointsAverage.x();
16617 const double dy = points.at(i).y()-pointsAverage.y();
16621 if (!qFuzzyIsNull(denomSum) && !qFuzzyIsNull(numSum))
16623 return qAtan2(numSum, denomSum);
16637 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QPointF(0, 0); }
16782 mBackgroundBrush(Qt::NoBrush),
16783 mBackgroundScaled(true),
16784 mBackgroundScaledMode(Qt::KeepAspectRatioByExpanding),
16786 mRangeDrag(Qt::Horizontal|Qt::Vertical),
16787 mRangeZoom(Qt::Horizontal|Qt::Vertical),
16788 mRangeZoomFactorHorz(0.85),
16789 mRangeZoomFactorVert(0.85),
16803 if (setupDefaultAxes)
16829 QList<QCPAxis*> axesList =
axes();
16830 for (
int i=0; i<axesList.size(); ++i)
16841 return mAxes.value(type).size();
16851 QList<QCPAxis*> ax(
mAxes.value(type));
16852 if (index >= 0 && index < ax.size())
16854 return ax.at(index);
16857 qDebug() << Q_FUNC_INFO <<
"Axis index out of bounds:" << index;
16872 QList<QCPAxis*> result;
16890 QList<QCPAxis*> result;
16891 QHashIterator<QCPAxis::AxisType, QList<QCPAxis*> > it(
mAxes);
16892 while (it.hasNext())
16895 result << it.value();
16925 newAxis =
new QCPAxis(
this, type);
16930 qDebug() << Q_FUNC_INFO <<
"passed axis has different axis type than specified in type parameter";
16935 qDebug() << Q_FUNC_INFO <<
"passed axis doesn't have this axis rect as parent axis rect";
16938 if (
axes().contains(newAxis))
16940 qDebug() << Q_FUNC_INFO <<
"passed axis is already owned by this axis rect";
16950 mAxes[type].append(newAxis);
16977 QList<QCPAxis*> result;
16999 QHashIterator<QCPAxis::AxisType, QList<QCPAxis*> > it(
mAxes);
17000 while (it.hasNext())
17003 if (it.value().contains(axis))
17005 if (it.value().first() == axis && it.value().size() > 1)
17006 it.value()[1]->setOffset(axis->
offset());
17007 mAxes[it.key()].removeOne(axis);
17008 if (qobject_cast<QCustomPlot*>(
parentPlot()))
17014 qDebug() << Q_FUNC_INFO <<
"Axis isn't in axis rect:" <<
reinterpret_cast<quintptr
>(
axis);
17045 qDebug() << Q_FUNC_INFO <<
"a passed axis was zero";
17050 pixelRange =
QCPRange(pixelRect.left(), pixelRect.right());
17052 pixelRange =
QCPRange(pixelRect.top(), pixelRect.bottom());
17078 QCPAxis *xAxis, *yAxis, *xAxis2, *yAxis2;
17112 xAxis2->
ticker()->setTickCount(xAxis->
ticker()->tickCount());
17113 xAxis2->
ticker()->setTickOrigin(xAxis->
ticker()->tickOrigin());
17121 yAxis2->
ticker()->setTickCount(yAxis->
ticker()->tickCount());
17122 yAxis2->
ticker()->setTickOrigin(yAxis->
ticker()->tickOrigin());
17126 connect(xAxis, SIGNAL(rangeChanged(
QCPRange)), xAxis2, SLOT(setRange(
QCPRange)));
17127 connect(yAxis, SIGNAL(rangeChanged(
QCPRange)), yAxis2, SLOT(setRange(
QCPRange)));
17142 QList<QCPAbstractPlottable*> result;
17162 QList<QCPGraph*> result;
17185 QList<QCPAbstractItem*> result;
17193 QList<QCPItemPosition*> positions =
mParentPlot->
mItems.at(itemId)->positions();
17194 for (
int posId=0; posId<positions.size(); ++posId)
17196 if (positions.at(posId)->axisRect() ==
this ||
17197 positions.at(posId)->keyAxis()->axisRect() ==
this ||
17198 positions.at(posId)->valueAxis()->axisRect() ==
this)
17226 QList<QCPAxis*> allAxes =
axes();
17227 for (
int i=0; i<allAxes.size(); ++i)
17228 allAxes.at(i)->setupTickVectors();
17246 QList<QCPLayoutElement*> result;
17251 result << mInsetLayout->
elements(recursive);
17355 if (orientation == Qt::Horizontal)
17369 if (orientation == Qt::Horizontal)
17382 QList<QCPAxis*> result;
17383 if (orientation == Qt::Horizontal)
17408 QList<QCPAxis*> result;
17409 if (orientation == Qt::Horizontal)
17490 QList<QCPAxis*> horz, vert;
17492 horz.append(horizontal);
17494 vert.append(vertical);
17509 QList<QCPAxis*> horz, vert;
17529 foreach (
QCPAxis *ax, horizontal)
17531 QPointer<QCPAxis> axPointer(ax);
17532 if (!axPointer.isNull())
17535 qDebug() << Q_FUNC_INFO <<
"invalid axis passed in horizontal list:" <<
reinterpret_cast<quintptr
>(ax);
17538 foreach (
QCPAxis *ax, vertical)
17540 QPointer<QCPAxis> axPointer(ax);
17541 if (!axPointer.isNull())
17544 qDebug() << Q_FUNC_INFO <<
"invalid axis passed in vertical list:" <<
reinterpret_cast<quintptr
>(ax);
17562 QList<QCPAxis*> horz, vert;
17564 horz.append(horizontal);
17566 vert.append(vertical);
17581 QList<QCPAxis*> horz, vert;
17601 foreach (
QCPAxis *ax, horizontal)
17603 QPointer<QCPAxis> axPointer(ax);
17604 if (!axPointer.isNull())
17607 qDebug() << Q_FUNC_INFO <<
"invalid axis passed in horizontal list:" <<
reinterpret_cast<quintptr
>(ax);
17610 foreach (
QCPAxis *ax, vertical)
17612 QPointer<QCPAxis> axPointer(ax);
17613 if (!axPointer.isNull())
17616 qDebug() << Q_FUNC_INFO <<
"invalid axis passed in vertical list:" <<
reinterpret_cast<quintptr
>(ax);
17700 const QList<QCPAxis*> axesList =
mAxes.value(type);
17701 if (axesList.isEmpty())
17704 bool isFirstVisible = !axesList.first()->visible();
17705 for (
int i=1; i<axesList.size(); ++i)
17707 int offset = axesList.at(i-1)->offset() + axesList.at(i-1)->calculateMargin();
17708 if (axesList.at(i)->visible())
17710 if (!isFirstVisible)
17711 offset += axesList.at(i)->tickLengthIn();
17712 isFirstVisible =
false;
17714 axesList.at(i)->setOffset(offset);
17722 qDebug() << Q_FUNC_INFO <<
"Called with side that isn't specified as auto margin";
17728 if (axesList.size() > 0)
17729 return axesList.last()->offset() + axesList.last()->calculateMargin();
17773 if (event->buttons() & Qt::LeftButton)
17896 double wheelSteps =
event->delta()/120.0;
17969 mParentLegend(parent),
17970 mFont(parent->font()),
17971 mTextColor(parent->textColor()),
17972 mSelectedFont(parent->selectedFont()),
17973 mSelectedTextColor(parent->selectedTextColor()),
17977 setLayer(QLatin1String(
"legend"));
18062 if (
mRect.contains(pos.toPoint()))
18089 if (selectionStateChanged)
18090 *selectionStateChanged =
mSelected != selBefore;
18101 if (selectionStateChanged)
18102 *selectionStateChanged =
mSelected != selBefore;
18143 mPlottable(plottable)
18190 QRectF textRect = painter->fontMetrics().boundingRect(0, 0, 0, iconSize.height(), Qt::TextDontClip,
mPlottable->
name());
18191 QRectF iconRect(
mRect.topLeft(), iconSize);
18192 int textHeight = qMax(textRect.height(), iconSize.height());
18196 painter->setClipRect(iconRect, Qt::IntersectClip);
18203 painter->setBrush(Qt::NoBrush);
18204 int halfPen = qCeil(painter->pen().widthF()*0.5)+1;
18205 painter->setClipRect(
mOuterRect.adjusted(-halfPen, -halfPen, halfPen, halfPen));
18206 painter->drawRect(iconRect);
18220 QSize result(0, 0);
18222 QFontMetrics fontMetrics(
getFont());
18224 textRect = fontMetrics.boundingRect(0, 0, 0, iconSize.height(), Qt::TextDontClip,
mPlottable->
name());
18226 result.setHeight(qMax(textRect.height(), iconSize.height()));
18294 setColumnSpacing(8);
18297 setIconSize(32, 18);
18299 setIconTextPadding(7);
18301 setSelectableParts(spLegendBox | spItems);
18302 setSelectedParts(spNone);
18304 setBorderPen(QPen(Qt::black, 0));
18305 setSelectedBorderPen(QPen(Qt::blue, 2));
18306 setIconBorderPen(Qt::NoPen);
18307 setSelectedIconBorderPen(QPen(Qt::blue, 2));
18308 setBrush(Qt::white);
18309 setSelectedBrush(Qt::white);
18325 bool hasSelectedItems =
false;
18326 for (
int i=0; i<itemCount(); ++i)
18328 if (item(i) && item(i)->selected())
18330 hasSelectedItems =
true;
18334 if (hasSelectedItems)
18335 return mSelectedParts | spItems;
18337 return mSelectedParts & ~spItems;
18368 for (
int i=0; i<itemCount(); ++i)
18371 item(i)->setFont(
mFont);
18387 for (
int i=0; i<itemCount(); ++i)
18390 item(i)->setTextColor(color);
18407 mIconSize.setWidth(width);
18408 mIconSize.setHeight(height);
18418 mIconTextPadding = padding;
18429 mIconBorderPen = pen;
18444 if (mSelectableParts != selectable)
18474 SelectableParts newSelected =
selected;
18475 mSelectedParts = this->selectedParts();
18477 if (mSelectedParts != newSelected)
18479 if (!mSelectedParts.testFlag(spItems) && newSelected.testFlag(spItems))
18481 qDebug() << Q_FUNC_INFO <<
"spItems flag can not be set, it can only be unset with this function";
18482 newSelected &= ~spItems;
18484 if (mSelectedParts.testFlag(spItems) && !newSelected.testFlag(spItems))
18486 for (
int i=0; i<itemCount(); ++i)
18489 item(i)->setSelected(
false);
18492 mSelectedParts = newSelected;
18505 mSelectedBorderPen = pen;
18515 mSelectedIconBorderPen = pen;
18526 mSelectedBrush = brush;
18539 for (
int i=0; i<itemCount(); ++i)
18542 item(i)->setSelectedFont(font);
18556 for (
int i=0; i<itemCount(); ++i)
18559 item(i)->setSelectedTextColor(color);
18583 for (
int i=0; i<itemCount(); ++i)
18604 return elementCount();
18614 for (
int i=0; i<itemCount(); ++i)
18616 if (item == this->item(i))
18630 return itemWithPlottable(plottable);
18645 return addElement(item);
18665 bool success =
remove(ali);
18667 setFillOrder(fillOrder(),
true);
18687 bool success =
remove(item);
18689 setFillOrder(fillOrder(),
true);
18698 for (
int i=itemCount()-1; i>=0; --i)
18710 QList<QCPAbstractLegendItem*> result;
18711 for (
int i=0; i<itemCount(); ++i)
18715 if (ali->selected())
18716 result.append(ali);
18749 return mSelectedParts.testFlag(spLegendBox) ? mSelectedBorderPen : mBorderPen;
18759 return mSelectedParts.testFlag(spLegendBox) ? mSelectedBrush : mBrush;
18770 painter->setBrush(getBrush());
18771 painter->
setPen(getBorderPen());
18779 if (onlySelectable && !mSelectableParts.testFlag(spLegendBox))
18784 if (details) details->setValue(spLegendBox);
18794 mSelectedParts = selectedParts();
18795 if (details.value<
SelectablePart>() == spLegendBox && mSelectableParts.testFlag(spLegendBox))
18797 SelectableParts selBefore = mSelectedParts;
18798 setSelectedParts(additive ? mSelectedParts^spLegendBox : mSelectedParts|spLegendBox);
18799 if (selectionStateChanged)
18800 *selectionStateChanged = mSelectedParts != selBefore;
18807 mSelectedParts = selectedParts();
18808 if (mSelectableParts.testFlag(spLegendBox))
18810 SelectableParts selBefore = mSelectedParts;
18811 setSelectedParts(selectedParts() & ~spLegendBox);
18812 if (selectionStateChanged)
18813 *selectionStateChanged = mSelectedParts != selBefore;
18832 if (parentPlot && !parentPlot->
legend)
18833 parentPlot->
legend =
this;
18889 mTextFlags(Qt::AlignCenter|Qt::TextWordWrap),
18890 mFont(QFont(QLatin1String(
"sans serif"), 12)),
18899 mFont = parentPlot->font();
18914 mTextFlags(Qt::AlignCenter|Qt::TextWordWrap),
18915 mFont(QFont(QLatin1String(
"sans serif"), 12)),
18924 mFont = parentPlot->font();
18939 mTextFlags(Qt::AlignCenter|Qt::TextWordWrap),
18940 mFont(QFont(QLatin1String(
"sans serif"), pointSize)),
18942 mSelectedFont(QFont(QLatin1String(
"sans serif"), pointSize)),
18949 mFont = parentPlot->font();
18950 mFont.setPointSizeF(pointSize);
18966 mTextFlags(Qt::AlignCenter|Qt::TextWordWrap),
18967 mFont(QFont(fontFamily, pointSize)),
18986 mTextFlags(Qt::AlignCenter|Qt::TextWordWrap),
19120 QFontMetrics metrics(
mFont);
19121 QSize result(metrics.boundingRect(0, 0, 0, 0, Qt::AlignCenter,
mText).size());
19130 QFontMetrics metrics(
mFont);
19131 QSize result(metrics.boundingRect(0, 0, 0, 0, Qt::AlignCenter,
mText).size());
19132 result.setWidth(QWIDGETSIZE_MAX);
19146 if (selectionStateChanged)
19147 *selectionStateChanged =
mSelected != selBefore;
19158 if (selectionStateChanged)
19159 *selectionStateChanged =
mSelected != selBefore;
19205 if ((QPointF(event->pos())-startPos).manhattanLength() <= 3)
19335 mDataScaleType(
QCPAxis::stLinear),
19354 qDebug() << Q_FUNC_INFO <<
"internal color axis undefined";
19366 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19380 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19400 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19407 QString labelTransfer;
19408 QSharedPointer<QCPAxisTicker> tickerTransfer;
19415 tickerTransfer =
mColorAxis.data()->ticker();
19433 mColorAxis.data()->setTicker(tickerTransfer);
19497 mAxisRect.data()->mGradientImageInvalidated =
true;
19510 qDebug() << Q_FUNC_INFO <<
"internal color axis undefined";
19536 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19556 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19571 QList<QCPColorMap*> result;
19575 if (cm->colorScale() ==
this)
19589 QList<QCPColorMap*> maps =
colorMaps();
19591 bool haveRange =
false;
19595 for (
int i=0; i<maps.size(); ++i)
19597 if (!maps.at(i)->realVisibility() && onlyVisibleMaps)
19600 if (maps.at(i)->colorScale() ==
this)
19602 bool currentFoundRange =
true;
19603 mapRange = maps.at(i)->data()->dataBounds();
19606 if (mapRange.
lower <= 0 && mapRange.
upper > 0)
19608 else if (mapRange.
lower <= 0 && mapRange.
upper <= 0)
19609 currentFoundRange =
false;
19612 if (mapRange.
upper >= 0 && mapRange.
lower < 0)
19614 else if (mapRange.
upper >= 0 && mapRange.
lower >= 0)
19615 currentFoundRange =
false;
19617 if (currentFoundRange)
19620 newRange = mapRange;
19622 newRange.
expand(mapRange);
19631 double center = (newRange.
lower+newRange.
upper)*0.5;
19652 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19693 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19696 mAxisRect.data()->mousePressEvent(event, details);
19704 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19707 mAxisRect.data()->mouseMoveEvent(event, startPos);
19715 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19718 mAxisRect.data()->mouseReleaseEvent(event, startPos);
19726 qDebug() << Q_FUNC_INFO <<
"internal axis rect was deleted";
19752 mParentColorScale(parentColorScale),
19753 mGradientImageInvalidated(true)
19763 connect(
axis(type), SIGNAL(selectionChanged(QCPAxis::SelectableParts)),
this, SLOT(
axisSelectionChanged(QCPAxis::SelectableParts)));
19764 connect(
axis(type), SIGNAL(selectableChanged(QCPAxis::SelectableParts)),
this, SLOT(
axisSelectableChanged(QCPAxis::SelectableParts)));
19795 bool mirrorHorz =
false;
19796 bool mirrorVert =
false;
19803 painter->drawImage(
rect().adjusted(0, -1, 0, -1),
mGradientImage.mirrored(mirrorHorz, mirrorVert));
19814 if (
rect().isEmpty())
19817 const QImage::Format format = QImage::Format_ARGB32_Premultiplied;
19820 QVector<double> data(n);
19821 for (
int i=0; i<n; ++i)
19826 h =
rect().height();
19828 QVector<QRgb*> pixels;
19829 for (
int y=0; y<h; ++y)
19830 pixels.append(reinterpret_cast<QRgb*>(
mGradientImage.scanLine(y)));
19832 for (
int y=1; y<h; ++y)
19833 memcpy(pixels.at(y), pixels.first(), n*
sizeof(QRgb));
19836 w =
rect().width();
19839 for (
int y=0; y<h; ++y)
19841 QRgb *pixels =
reinterpret_cast<QRgb*
>(
mGradientImage.scanLine(y));
19843 for (
int x=0; x<w; ++x)
19844 pixels[x] = lineColor;
19861 if (
QCPAxis *senderAxis = qobject_cast<QCPAxis*>(sender()))
19862 if (senderAxis->axisType() == type)
19886 if (
QCPAxis *senderAxis = qobject_cast<QCPAxis*>(sender()))
19887 if (senderAxis->axisType() == type)
20066 setPen(QPen(Qt::blue, 0));
20113 addData(keys, values, alreadySorted);
20166 if (targetGraph ==
this)
20168 qDebug() << Q_FUNC_INFO <<
"targetGraph is this graph itself";
20175 qDebug() << Q_FUNC_INFO <<
"targetGraph not in same plot";
20233 if (keys.size() != values.size())
20234 qDebug() << Q_FUNC_INFO <<
"keys and values have different sizes:" << keys.size() << values.size();
20235 const int n = qMin(keys.size(), values.size());
20236 QVector<QCPGraphData> tempData(n);
20237 QVector<QCPGraphData>::iterator it = tempData.begin();
20238 const QVector<QCPGraphData>::iterator itEnd = tempData.end();
20240 while (it != itEnd)
20243 it->value = values[i];
20270 if (
mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint()))
20293 return mDataContainer->valueRange(foundRange, inSignDomain, inKeyRange);
20299 if (!
mKeyAxis || !
mValueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
20303 QVector<QPointF> lines, scatters;
20306 QList<QCPDataRange> selectedSegments, unselectedSegments, allSegments;
20308 allSegments << unselectedSegments << selectedSegments;
20309 for (
int i=0; i<allSegments.size(); ++i)
20311 bool isSelectedSegment = i >= unselectedSegments.size();
20313 QCPDataRange lineDataRange = isSelectedSegment ? allSegments.at(i) : allSegments.at(i).
adjusted(-1, 1);
20317 #ifdef QCUSTOMPLOT_CHECK_DATA 20322 qDebug() << Q_FUNC_INFO <<
"Data point at" << it->key <<
"invalid." <<
"Plottable name:" <<
name();
20330 painter->setBrush(
mBrush);
20331 painter->
setPen(Qt::NoPen);
20341 painter->setBrush(Qt::NoBrush);
20352 if (!finalScatterStyle.
isNone())
20368 if (
mBrush.style() != Qt::NoBrush)
20371 painter->fillRect(QRectF(rect.left(), rect.top()+rect.height()/2.0, rect.width(), rect.height()/3.0),
mBrush);
20378 painter->
drawLine(QLineF(rect.left(), rect.top()+rect.height()/2.0, rect.right()+5, rect.top()+rect.height()/2.0));
20388 scaledStyle.
setPixmap(scaledStyle.
pixmap().scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
20390 scaledStyle.
drawShape(painter, QRectF(rect).center());
20421 if (!lines)
return;
20430 QVector<QCPGraphData> lineData;
20434 if (
mKeyAxis->rangeReversed() != (
mKeyAxis->orientation() == Qt::Vertical))
20435 std::reverse(lineData.begin(), lineData.end());
20439 case lsNone: lines->clear();
break;
20462 if (!scatters)
return;
20465 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis"; scatters->clear();
return; }
20475 QVector<QCPGraphData>
data;
20478 if (
mKeyAxis->rangeReversed() != (
mKeyAxis->orientation() == Qt::Vertical))
20479 std::reverse(data.begin(), data.end());
20481 scatters->resize(data.size());
20484 for (
int i=0; i<data.size(); ++i)
20486 if (!qIsNaN(data.at(i).value))
20488 (*scatters)[i].setX(valueAxis->
coordToPixel(data.at(i).value));
20489 (*scatters)[i].setY(keyAxis->
coordToPixel(data.at(i).key));
20494 for (
int i=0; i<data.size(); ++i)
20496 if (!qIsNaN(data.at(i).value))
20498 (*scatters)[i].setX(keyAxis->
coordToPixel(data.at(i).key));
20499 (*scatters)[i].setY(valueAxis->
coordToPixel(data.at(i).value));
20517 QVector<QPointF> result;
20520 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return result; }
20522 result.resize(data.size());
20527 for (
int i=0; i<data.size(); ++i)
20529 result[i].setX(valueAxis->
coordToPixel(data.at(i).value));
20530 result[i].setY(keyAxis->
coordToPixel(data.at(i).key));
20534 for (
int i=0; i<data.size(); ++i)
20536 result[i].setX(keyAxis->
coordToPixel(data.at(i).key));
20537 result[i].setY(valueAxis->
coordToPixel(data.at(i).value));
20555 QVector<QPointF> result;
20558 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return result; }
20560 result.resize(data.size()*2);
20565 double lastValue = valueAxis->
coordToPixel(data.first().value);
20566 for (
int i=0; i<data.size(); ++i)
20568 const double key = keyAxis->
coordToPixel(data.at(i).key);
20569 result[i*2+0].setX(lastValue);
20570 result[i*2+0].setY(key);
20571 lastValue = valueAxis->
coordToPixel(data.at(i).value);
20572 result[i*2+1].setX(lastValue);
20573 result[i*2+1].setY(key);
20577 double lastValue = valueAxis->
coordToPixel(data.first().value);
20578 for (
int i=0; i<data.size(); ++i)
20580 const double key = keyAxis->
coordToPixel(data.at(i).key);
20581 result[i*2+0].setX(key);
20582 result[i*2+0].setY(lastValue);
20583 lastValue = valueAxis->
coordToPixel(data.at(i).value);
20584 result[i*2+1].setX(key);
20585 result[i*2+1].setY(lastValue);
20603 QVector<QPointF> result;
20606 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return result; }
20608 result.resize(data.size()*2);
20613 double lastKey = keyAxis->
coordToPixel(data.first().key);
20614 for (
int i=0; i<data.size(); ++i)
20616 const double value = valueAxis->
coordToPixel(data.at(i).value);
20617 result[i*2+0].setX(value);
20618 result[i*2+0].setY(lastKey);
20620 result[i*2+1].setX(value);
20621 result[i*2+1].setY(lastKey);
20625 double lastKey = keyAxis->
coordToPixel(data.first().key);
20626 for (
int i=0; i<data.size(); ++i)
20628 const double value = valueAxis->
coordToPixel(data.at(i).value);
20629 result[i*2+0].setX(lastKey);
20630 result[i*2+0].setY(value);
20632 result[i*2+1].setX(lastKey);
20633 result[i*2+1].setY(value);
20651 QVector<QPointF> result;
20654 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return result; }
20656 result.resize(data.size()*2);
20661 double lastKey = keyAxis->
coordToPixel(data.first().key);
20662 double lastValue = valueAxis->
coordToPixel(data.first().value);
20663 result[0].setX(lastValue);
20664 result[0].setY(lastKey);
20665 for (
int i=1; i<data.size(); ++i)
20667 const double key = (keyAxis->
coordToPixel(data.at(i).key)+lastKey)*0.5;
20668 result[i*2-1].setX(lastValue);
20669 result[i*2-1].setY(key);
20670 lastValue = valueAxis->
coordToPixel(data.at(i).value);
20672 result[i*2+0].setX(lastValue);
20673 result[i*2+0].setY(key);
20675 result[data.size()*2-1].setX(lastValue);
20676 result[data.size()*2-1].setY(lastKey);
20679 double lastKey = keyAxis->
coordToPixel(data.first().key);
20680 double lastValue = valueAxis->
coordToPixel(data.first().value);
20681 result[0].setX(lastKey);
20682 result[0].setY(lastValue);
20683 for (
int i=1; i<data.size(); ++i)
20685 const double key = (keyAxis->
coordToPixel(data.at(i).key)+lastKey)*0.5;
20686 result[i*2-1].setX(key);
20687 result[i*2-1].setY(lastValue);
20688 lastValue = valueAxis->
coordToPixel(data.at(i).value);
20690 result[i*2+0].setX(key);
20691 result[i*2+0].setY(lastValue);
20693 result[data.size()*2-1].setX(lastKey);
20694 result[data.size()*2-1].setY(lastValue);
20711 QVector<QPointF> result;
20714 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return result; }
20716 result.resize(data.size()*2);
20721 for (
int i=0; i<data.size(); ++i)
20723 const double key = keyAxis->
coordToPixel(data.at(i).key);
20725 result[i*2+0].setY(key);
20726 result[i*2+1].setX(valueAxis->
coordToPixel(data.at(i).value));
20727 result[i*2+1].setY(key);
20731 for (
int i=0; i<data.size(); ++i)
20733 const double key = keyAxis->
coordToPixel(data.at(i).key);
20734 result[i*2+0].setX(key);
20736 result[i*2+1].setX(key);
20737 result[i*2+1].setY(valueAxis->
coordToPixel(data.at(i).value));
20763 if (painter->brush().style() == Qt::NoBrush || painter->brush().color().alpha() == 0)
return;
20770 for (
int i=0; i<segments.size(); ++i)
20775 QVector<QPointF> otherLines;
20777 if (!otherLines.isEmpty())
20780 QVector<QPair<QCPDataRange, QCPDataRange> > segmentPairs =
getOverlappingSegments(segments, lines, otherSegments, &otherLines);
20781 for (
int i=0; i<segmentPairs.size(); ++i)
20782 painter->drawPolygon(
getChannelFillPolygon(lines, segmentPairs.at(i).first, &otherLines, segmentPairs.at(i).second));
20798 for (
int i=0; i<scatters.size(); ++i)
20799 style.
drawShape(painter, scatters.at(i).x(), scatters.at(i).y());
20810 if (painter->pen().style() != Qt::NoPen && painter->pen().color().alpha() != 0)
20827 if (painter->pen().style() != Qt::NoPen && painter->pen().color().alpha() != 0)
20830 QPen oldPen = painter->pen();
20831 QPen newPen = painter->pen();
20832 newPen.setCapStyle(Qt::FlatCap);
20833 painter->
setPen(newPen);
20834 painter->drawLines(lines);
20835 painter->
setPen(oldPen);
20853 if (!lineData)
return;
20856 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
20857 if (begin == end)
return;
20860 int maxCount = std::numeric_limits<int>::max();
20864 if (2*keyPixelSpan+2 < (
double)std::numeric_limits<int>::max())
20865 maxCount = 2*keyPixelSpan+2;
20871 double minValue = it->value;
20872 double maxValue = it->value;
20875 int reversedRound = reversedFactor==-1 ? 1 : 0;
20877 double lastIntervalEndKey = currentIntervalStartKey;
20878 double keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->
pixelToCoord(keyAxis->
coordToPixel(currentIntervalStartKey)+1.0*reversedFactor));
20880 int intervalDataCount = 1;
20884 if (it->key < currentIntervalStartKey+keyEpsilon)
20886 if (it->value < minValue)
20887 minValue = it->value;
20888 else if (it->value > maxValue)
20889 maxValue = it->value;
20890 ++intervalDataCount;
20893 if (intervalDataCount >= 2)
20895 if (lastIntervalEndKey < currentIntervalStartKey-keyEpsilon)
20896 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.2, currentIntervalFirstPoint->value));
20897 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.25, minValue));
20898 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.75, maxValue));
20899 if (it->key > currentIntervalStartKey+keyEpsilon*2)
20900 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.8, (it-1)->value));
20902 lineData->append(
QCPGraphData(currentIntervalFirstPoint->key, currentIntervalFirstPoint->value));
20903 lastIntervalEndKey = (it-1)->key;
20904 minValue = it->value;
20905 maxValue = it->value;
20906 currentIntervalFirstPoint = it;
20908 if (keyEpsilonVariable)
20909 keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->
pixelToCoord(keyAxis->
coordToPixel(currentIntervalStartKey)+1.0*reversedFactor));
20910 intervalDataCount = 1;
20915 if (intervalDataCount >= 2)
20917 if (lastIntervalEndKey < currentIntervalStartKey-keyEpsilon)
20918 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.2, currentIntervalFirstPoint->value));
20919 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.25, minValue));
20920 lineData->append(
QCPGraphData(currentIntervalStartKey+keyEpsilon*0.75, maxValue));
20922 lineData->append(
QCPGraphData(currentIntervalFirstPoint->key, currentIntervalFirstPoint->value));
20926 lineData->resize(dataCount);
20927 std::copy(begin, end, lineData->begin());
20945 if (!scatterData)
return;
20948 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
20954 while (doScatterSkip && begin != end && beginIndex % scatterModulo != 0)
20959 if (begin == end)
return;
20961 int maxCount = std::numeric_limits<int>::max();
20965 maxCount = 2*keyPixelSpan+2;
20970 double valueMaxRange = valueAxis->
range().
upper;
20971 double valueMinRange = valueAxis->
range().
lower;
20973 int itIndex = beginIndex;
20974 double minValue = it->value;
20975 double maxValue = it->value;
20980 int reversedRound = reversedFactor==-1 ? 1 : 0;
20982 double keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->
pixelToCoord(keyAxis->
coordToPixel(currentIntervalStartKey)+1.0*reversedFactor));
20984 int intervalDataCount = 1;
20986 if (!doScatterSkip)
20990 itIndex += scatterModulo;
20991 if (itIndex < endIndex)
20992 it += scatterModulo;
20996 itIndex = endIndex;
21002 if (it->key < currentIntervalStartKey+keyEpsilon)
21004 if (it->value < minValue && it->value > valueMinRange && it->value < valueMaxRange)
21006 minValue = it->value;
21008 }
else if (it->value > maxValue && it->value > valueMinRange && it->value < valueMaxRange)
21010 maxValue = it->value;
21013 ++intervalDataCount;
21016 if (intervalDataCount >= 2)
21020 int dataModulo = qMax(1, qRound(intervalDataCount/(valuePixelSpan/4.0)));
21023 while (intervalIt != it)
21025 if ((c % dataModulo == 0 || intervalIt == minValueIt || intervalIt == maxValueIt) && intervalIt->value > valueMinRange && intervalIt->value < valueMaxRange)
21026 scatterData->append(*intervalIt);
21028 if (!doScatterSkip)
21031 intervalIt += scatterModulo;
21033 }
else if (currentIntervalStart->value > valueMinRange && currentIntervalStart->value < valueMaxRange)
21034 scatterData->append(*currentIntervalStart);
21035 minValue = it->value;
21036 maxValue = it->value;
21037 currentIntervalStart = it;
21039 if (keyEpsilonVariable)
21040 keyEpsilon = qAbs(currentIntervalStartKey-keyAxis->
pixelToCoord(keyAxis->
coordToPixel(currentIntervalStartKey)+1.0*reversedFactor));
21041 intervalDataCount = 1;
21044 if (!doScatterSkip)
21048 itIndex += scatterModulo;
21049 if (itIndex < endIndex)
21050 it += scatterModulo;
21054 itIndex = endIndex;
21059 if (intervalDataCount >= 2)
21063 int dataModulo = qMax(1, qRound(intervalDataCount/(valuePixelSpan/4.0)));
21067 while (intervalIt != it)
21069 if ((c % dataModulo == 0 || intervalIt == minValueIt || intervalIt == maxValueIt) && intervalIt->value > valueMinRange && intervalIt->value < valueMaxRange)
21070 scatterData->append(*intervalIt);
21072 if (!doScatterSkip)
21076 intervalItIndex += scatterModulo;
21077 if (intervalItIndex < itIndex)
21078 intervalIt += scatterModulo;
21082 intervalItIndex = itIndex;
21086 }
else if (currentIntervalStart->value > valueMinRange && currentIntervalStart->value < valueMaxRange)
21087 scatterData->append(*currentIntervalStart);
21092 int itIndex = beginIndex;
21093 scatterData->reserve(dataCount);
21096 scatterData->append(*it);
21098 if (!doScatterSkip)
21102 itIndex += scatterModulo;
21103 if (itIndex < endIndex)
21104 it += scatterModulo;
21108 itIndex = endIndex;
21126 if (rangeRestriction.
isEmpty())
21134 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
21139 mDataContainer->limitIteratorsToDataRange(begin, end, rangeRestriction);
21156 QVector<QCPDataRange> result;
21157 const int n = lineData->size();
21162 if (keyOrientation == Qt::Horizontal)
21166 while (i < n && qIsNaN(lineData->at(i).y()))
21171 while (i < n && !qIsNaN(lineData->at(i).y()))
21173 currentSegment.
setEnd(i++);
21174 result.append(currentSegment);
21180 while (i < n && qIsNaN(lineData->at(i).x()))
21185 while (i < n && !qIsNaN(lineData->at(i).x()))
21187 currentSegment.
setEnd(i++);
21188 result.append(currentSegment);
21212 QVector<QPair<QCPDataRange, QCPDataRange> >
QCPGraph::getOverlappingSegments(QVector<QCPDataRange> thisSegments,
const QVector<QPointF> *thisData, QVector<QCPDataRange> otherSegments,
const QVector<QPointF> *otherData)
const 21214 QVector<QPair<QCPDataRange, QCPDataRange> > result;
21215 if (thisData->isEmpty() || otherData->isEmpty() || thisSegments.isEmpty() || otherSegments.isEmpty())
21219 int otherIndex = 0;
21220 const bool verticalKey =
mKeyAxis->orientation() == Qt::Vertical;
21221 while (thisIndex < thisSegments.size() && otherIndex < otherSegments.size())
21223 if (thisSegments.at(thisIndex).size() < 2)
21228 if (otherSegments.at(otherIndex).size() < 2)
21233 double thisLower, thisUpper, otherLower, otherUpper;
21236 thisLower = thisData->at(thisSegments.at(thisIndex).begin()).x();
21237 thisUpper = thisData->at(thisSegments.at(thisIndex).end()-1).x();
21238 otherLower = otherData->at(otherSegments.at(otherIndex).begin()).x();
21239 otherUpper = otherData->at(otherSegments.at(otherIndex).end()-1).x();
21242 thisLower = thisData->at(thisSegments.at(thisIndex).begin()).y();
21243 thisUpper = thisData->at(thisSegments.at(thisIndex).end()-1).y();
21244 otherLower = otherData->at(otherSegments.at(otherIndex).begin()).y();
21245 otherUpper = otherData->at(otherSegments.at(otherIndex).end()-1).y();
21249 if (
segmentsIntersect(thisLower, thisUpper, otherLower, otherUpper, bPrecedence))
21250 result.append(QPair<QCPDataRange, QCPDataRange>(thisSegments.at(thisIndex), otherSegments.at(otherIndex)));
21252 if (bPrecedence <= 0)
21278 if (aLower > bUpper)
21282 }
else if (bLower > aUpper)
21288 if (aUpper > bUpper)
21290 else if (aUpper < bUpper)
21312 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QPointF(); }
21319 result.setX(matchingDataPoint.x());
21324 result.setY(matchingDataPoint.y());
21337 result.setY(matchingDataPoint.y());
21340 result.setX(matchingDataPoint.x());
21369 if (segment.
size() < 2)
21370 return QPolygonF();
21371 QPolygonF result(segment.
size()+2);
21374 std::copy(lineData->constBegin()+segment.
begin(), lineData->constBegin()+segment.
end(), result.begin()+1);
21401 return QPolygonF();
21405 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QPolygonF(); }
21406 if (!
mChannelFillGraph.data()->mKeyAxis) { qDebug() << Q_FUNC_INFO <<
"channel fill target key axis invalid";
return QPolygonF(); }
21409 return QPolygonF();
21411 if (thisData->isEmpty())
return QPolygonF();
21412 QVector<QPointF> thisSegmentData(thisSegment.
size());
21413 QVector<QPointF> otherSegmentData(otherSegment.
size());
21414 std::copy(thisData->constBegin()+thisSegment.
begin(), thisData->constBegin()+thisSegment.
end(), thisSegmentData.begin());
21415 std::copy(otherData->constBegin()+otherSegment.
begin(), otherData->constBegin()+otherSegment.
end(), otherSegmentData.begin());
21417 QVector<QPointF> *staticData = &thisSegmentData;
21418 QVector<QPointF> *croppedData = &otherSegmentData;
21425 if (staticData->first().x() < croppedData->first().x())
21426 qSwap(staticData, croppedData);
21427 const int lowBound =
findIndexBelowX(croppedData, staticData->first().x());
21428 if (lowBound == -1)
return QPolygonF();
21429 croppedData->remove(0, lowBound);
21431 if (croppedData->size() < 2)
return QPolygonF();
21433 if (!qFuzzyCompare(croppedData->at(1).x(), croppedData->at(0).x()))
21434 slope = (croppedData->at(1).y()-croppedData->at(0).y())/(croppedData->at(1).x()-croppedData->at(0).x());
21437 (*croppedData)[0].setY(croppedData->at(0).y()+slope*(staticData->first().x()-croppedData->at(0).x()));
21438 (*croppedData)[0].setX(staticData->first().x());
21441 if (staticData->last().x() > croppedData->last().x())
21442 qSwap(staticData, croppedData);
21443 int highBound =
findIndexAboveX(croppedData, staticData->last().x());
21444 if (highBound == -1)
return QPolygonF();
21445 croppedData->remove(highBound+1, croppedData->size()-(highBound+1));
21447 if (croppedData->size() < 2)
return QPolygonF();
21448 const int li = croppedData->size()-1;
21449 if (!qFuzzyCompare(croppedData->at(li).x(), croppedData->at(li-1).x()))
21450 slope = (croppedData->at(li).y()-croppedData->at(li-1).y())/(croppedData->at(li).x()-croppedData->at(li-1).x());
21453 (*croppedData)[li].setY(croppedData->at(li-1).y()+slope*(staticData->last().x()-croppedData->at(li-1).x()));
21454 (*croppedData)[li].setX(staticData->last().x());
21459 if (staticData->first().y() < croppedData->first().y())
21460 qSwap(staticData, croppedData);
21461 int lowBound =
findIndexBelowY(croppedData, staticData->first().y());
21462 if (lowBound == -1)
return QPolygonF();
21463 croppedData->remove(0, lowBound);
21465 if (croppedData->size() < 2)
return QPolygonF();
21467 if (!qFuzzyCompare(croppedData->at(1).y(), croppedData->at(0).y()))
21468 slope = (croppedData->at(1).x()-croppedData->at(0).x())/(croppedData->at(1).y()-croppedData->at(0).y());
21471 (*croppedData)[0].setX(croppedData->at(0).x()+slope*(staticData->first().y()-croppedData->at(0).y()));
21472 (*croppedData)[0].setY(staticData->first().y());
21475 if (staticData->last().y() > croppedData->last().y())
21476 qSwap(staticData, croppedData);
21477 int highBound =
findIndexAboveY(croppedData, staticData->last().y());
21478 if (highBound == -1)
return QPolygonF();
21479 croppedData->remove(highBound+1, croppedData->size()-(highBound+1));
21481 if (croppedData->size() < 2)
return QPolygonF();
21482 int li = croppedData->size()-1;
21483 if (!qFuzzyCompare(croppedData->at(li).y(), croppedData->at(li-1).y()))
21484 slope = (croppedData->at(li).x()-croppedData->at(li-1).x())/(croppedData->at(li).y()-croppedData->at(li-1).y());
21487 (*croppedData)[li].setX(croppedData->at(li-1).x()+slope*(staticData->last().y()-croppedData->at(li-1).y()));
21488 (*croppedData)[li].setY(staticData->last().y());
21492 for (
int i=otherSegmentData.size()-1; i>=0; --i)
21493 thisSegmentData << otherSegmentData.at(i);
21494 return QPolygonF(thisSegmentData);
21507 for (
int i=data->size()-1; i>=0; --i)
21509 if (data->at(i).x() < x)
21511 if (i<data->size()-1)
21514 return data->size()-1;
21530 for (
int i=0; i<data->size(); ++i)
21532 if (data->at(i).x() > x)
21553 for (
int i=data->size()-1; i>=0; --i)
21555 if (data->at(i).y() < y)
21557 if (i<data->size()-1)
21560 return data->size()-1;
21586 double minDistSqr = std::numeric_limits<double>::max();
21588 double posKeyMin, posKeyMax, dummy;
21591 if (posKeyMin > posKeyMax)
21592 qSwap(posKeyMin, posKeyMax);
21599 if (currentDistSqr < minDistSqr)
21601 minDistSqr = currentDistSqr;
21610 QVector<QPointF> lineData;
21614 for (
int i=0; i<lineData.size()-1; i+=step)
21617 if (currentDistSqr < minDistSqr)
21618 minDistSqr = currentDistSqr;
21622 return qSqrt(minDistSqr);
21635 for (
int i=0; i<data->size(); ++i)
21637 if (data->at(i).y() > y)
21812 setPen(QPen(Qt::blue, 0));
21855 void QCPCurve::setData(
const QVector<double> &t,
const QVector<double> &keys,
const QVector<double> &values,
bool alreadySorted)
21858 addData(t, keys, values, alreadySorted);
21931 void QCPCurve::addData(
const QVector<double> &t,
const QVector<double> &keys,
const QVector<double> &values,
bool alreadySorted)
21933 if (t.size() != keys.size() || t.size() != values.size())
21934 qDebug() << Q_FUNC_INFO <<
"ts, keys and values have different sizes:" << t.size() << keys.size() << values.size();
21935 const int n = qMin(qMin(t.size(), keys.size()), values.size());
21936 QVector<QCPCurveData> tempData(n);
21937 QVector<QCPCurveData>::iterator it = tempData.begin();
21938 const QVector<QCPCurveData>::iterator itEnd = tempData.end();
21940 while (it != itEnd)
21944 it->value = values[i];
21965 if (keys.size() != values.size())
21966 qDebug() << Q_FUNC_INFO <<
"keys and values have different sizes:" << keys.size() << values.size();
21967 const int n = qMin(keys.size(), values.size());
21973 QVector<QCPCurveData> tempData(n);
21974 QVector<QCPCurveData>::iterator it = tempData.begin();
21975 const QVector<QCPCurveData>::iterator itEnd = tempData.end();
21977 while (it != itEnd)
21979 it->t = tStart + i;
21981 it->value = values[i];
22025 if (
mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint()))
22048 return mDataContainer->valueRange(foundRange, inSignDomain, inKeyRange);
22057 QVector<QPointF> lines, scatters;
22060 QList<QCPDataRange> selectedSegments, unselectedSegments, allSegments;
22062 allSegments << unselectedSegments << selectedSegments;
22063 for (
int i=0; i<allSegments.size(); ++i)
22065 bool isSelectedSegment = i >= unselectedSegments.size();
22068 QPen finalCurvePen =
mPen;
22072 QCPDataRange lineDataRange = isSelectedSegment ? allSegments.at(i) : allSegments.at(i).
adjusted(-1, 1);
22073 getCurveLines(&lines, lineDataRange, finalCurvePen.widthF());
22076 #ifdef QCUSTOMPLOT_CHECK_DATA 22081 qDebug() << Q_FUNC_INFO <<
"Data point at" << it->key <<
"invalid." <<
"Plottable name:" <<
name();
22090 painter->setBrush(
mBrush);
22091 painter->
setPen(Qt::NoPen);
22092 if (painter->brush().style() != Qt::NoBrush && painter->brush().color().alpha() != 0)
22093 painter->drawPolygon(QPolygonF(lines));
22098 painter->
setPen(finalCurvePen);
22099 painter->setBrush(Qt::NoBrush);
22107 if (!finalScatterStyle.
isNone())
22123 if (
mBrush.style() != Qt::NoBrush)
22126 painter->fillRect(QRectF(rect.left(), rect.top()+rect.height()/2.0, rect.width(), rect.height()/3.0),
mBrush);
22133 painter->
drawLine(QLineF(rect.left(), rect.top()+rect.height()/2.0, rect.right()+5, rect.top()+rect.height()/2.0));
22143 scaledStyle.
setPixmap(scaledStyle.
pixmap().scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::SmoothTransformation));
22145 scaledStyle.
drawShape(painter, QRectF(rect).center());
22162 if (painter->pen().style() != Qt::NoPen && painter->pen().color().alpha() != 0)
22181 for (
int i=0; i<points.size(); ++i)
22182 if (!qIsNaN(points.at(i).x()) && !qIsNaN(points.at(i).y()))
22183 style.
drawShape(painter, points.at(i));
22216 if (!lines)
return;
22220 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
22223 const double strokeMargin = qMax(qreal(1.0), qreal(penWidth*0.75));
22230 mDataContainer->limitIteratorsToDataRange(itBegin, itEnd, dataRange);
22231 if (itBegin == itEnd)
22235 int prevRegion =
getRegion(prevIt->key, prevIt->value, keyMin, valueMax, keyMax, valueMin);
22236 QVector<QPointF> trailingPoints;
22237 while (it != itEnd)
22239 const int currentRegion =
getRegion(it->key, it->value, keyMin, valueMax, keyMax, valueMin);
22240 if (currentRegion != prevRegion)
22242 if (currentRegion != 5)
22244 QPointF crossA, crossB;
22245 if (prevRegion == 5)
22247 lines->append(
getOptimizedPoint(currentRegion, it->key, it->value, prevIt->key, prevIt->value, keyMin, valueMax, keyMax, valueMin));
22249 *lines <<
getOptimizedCornerPoints(prevRegion, currentRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin);
22250 }
else if (
mayTraverse(prevRegion, currentRegion) &&
22251 getTraverse(prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin, crossA, crossB))
22254 QVector<QPointF> beforeTraverseCornerPoints, afterTraverseCornerPoints;
22255 getTraverseCornerPoints(prevRegion, currentRegion, keyMin, valueMax, keyMax, valueMin, beforeTraverseCornerPoints, afterTraverseCornerPoints);
22258 *lines << beforeTraverseCornerPoints;
22259 lines->append(crossA);
22260 lines->append(crossB);
22261 *lines << afterTraverseCornerPoints;
22264 lines->append(crossB);
22265 *lines << afterTraverseCornerPoints;
22266 trailingPoints << beforeTraverseCornerPoints << crossA ;
22270 *lines <<
getOptimizedCornerPoints(prevRegion, currentRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin);
22275 trailingPoints <<
getOptimizedPoint(prevRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin);
22277 lines->append(
getOptimizedPoint(prevRegion, prevIt->key, prevIt->value, it->key, it->value, keyMin, valueMax, keyMax, valueMin));
22282 if (currentRegion == 5)
22291 prevRegion = currentRegion;
22294 *lines << trailingPoints;
22319 if (!scatters)
return;
22323 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
22327 mDataContainer->limitIteratorsToDataRange(begin, end, dataRange);
22344 while (doScatterSkip && it != end && itIndex % scatterModulo != 0)
22353 if (!qIsNaN(it->value) && keyRange.
contains(it->key) && valueRange.
contains(it->value))
22357 if (!doScatterSkip)
22361 itIndex += scatterModulo;
22362 if (itIndex < endIndex)
22363 it += scatterModulo;
22367 itIndex = endIndex;
22375 if (!qIsNaN(it->value) && keyRange.
contains(it->key) && valueRange.
contains(it->value))
22379 if (!doScatterSkip)
22383 itIndex += scatterModulo;
22384 if (itIndex < endIndex)
22385 it += scatterModulo;
22389 itIndex = endIndex;
22415 int QCPCurve::getRegion(
double key,
double value,
double keyMin,
double valueMax,
double keyMax,
double valueMin)
const 22419 if (value > valueMax)
22421 else if (value < valueMin)
22425 }
else if (key > keyMax)
22427 if (value > valueMax)
22429 else if (value < valueMin)
22435 if (value > valueMax)
22437 else if (value < valueMin)
22459 QPointF
QCPCurve::getOptimizedPoint(
int otherRegion,
double otherKey,
double otherValue,
double key,
double value,
double keyMin,
double valueMax,
double keyMax,
double valueMin)
const 22466 const double keyMinPx =
mKeyAxis->coordToPixel(keyMin);
22467 const double keyMaxPx =
mKeyAxis->coordToPixel(keyMax);
22468 const double valueMinPx =
mValueAxis->coordToPixel(valueMin);
22469 const double valueMaxPx =
mValueAxis->coordToPixel(valueMax);
22470 const double otherValuePx =
mValueAxis->coordToPixel(otherValue);
22471 const double valuePx =
mValueAxis->coordToPixel(value);
22472 const double otherKeyPx =
mKeyAxis->coordToPixel(otherKey);
22473 const double keyPx =
mKeyAxis->coordToPixel(key);
22474 double intersectKeyPx = keyMinPx;
22475 double intersectValuePx = valueMinPx;
22476 switch (otherRegion)
22480 intersectValuePx = valueMaxPx;
22481 intersectKeyPx = otherKeyPx + (keyPx-otherKeyPx)/(valuePx-otherValuePx)*(intersectValuePx-otherValuePx);
22482 if (intersectKeyPx < qMin(keyMinPx, keyMaxPx) || intersectKeyPx > qMax(keyMinPx, keyMaxPx))
22484 intersectKeyPx = keyMinPx;
22485 intersectValuePx = otherValuePx + (valuePx-otherValuePx)/(keyPx-otherKeyPx)*(intersectKeyPx-otherKeyPx);
22491 intersectKeyPx = keyMinPx;
22492 intersectValuePx = otherValuePx + (valuePx-otherValuePx)/(keyPx-otherKeyPx)*(intersectKeyPx-otherKeyPx);
22497 intersectValuePx = valueMinPx;
22498 intersectKeyPx = otherKeyPx + (keyPx-otherKeyPx)/(valuePx-otherValuePx)*(intersectValuePx-otherValuePx);
22499 if (intersectKeyPx < qMin(keyMinPx, keyMaxPx) || intersectKeyPx > qMax(keyMinPx, keyMaxPx))
22501 intersectKeyPx = keyMinPx;
22502 intersectValuePx = otherValuePx + (valuePx-otherValuePx)/(keyPx-otherKeyPx)*(intersectKeyPx-otherKeyPx);
22508 intersectValuePx = valueMaxPx;
22509 intersectKeyPx = otherKeyPx + (keyPx-otherKeyPx)/(valuePx-otherValuePx)*(intersectValuePx-otherValuePx);
22518 intersectValuePx = valueMinPx;
22519 intersectKeyPx = otherKeyPx + (keyPx-otherKeyPx)/(valuePx-otherValuePx)*(intersectValuePx-otherValuePx);
22524 intersectValuePx = valueMaxPx;
22525 intersectKeyPx = otherKeyPx + (keyPx-otherKeyPx)/(valuePx-otherValuePx)*(intersectValuePx-otherValuePx);
22526 if (intersectKeyPx < qMin(keyMinPx, keyMaxPx) || intersectKeyPx > qMax(keyMinPx, keyMaxPx))
22528 intersectKeyPx = keyMaxPx;
22529 intersectValuePx = otherValuePx + (valuePx-otherValuePx)/(keyPx-otherKeyPx)*(intersectKeyPx-otherKeyPx);
22535 intersectKeyPx = keyMaxPx;
22536 intersectValuePx = otherValuePx + (valuePx-otherValuePx)/(keyPx-otherKeyPx)*(intersectKeyPx-otherKeyPx);
22541 intersectValuePx = valueMinPx;
22542 intersectKeyPx = otherKeyPx + (keyPx-otherKeyPx)/(valuePx-otherValuePx)*(intersectValuePx-otherValuePx);
22543 if (intersectKeyPx < qMin(keyMinPx, keyMaxPx) || intersectKeyPx > qMax(keyMinPx, keyMaxPx))
22545 intersectKeyPx = keyMaxPx;
22546 intersectValuePx = otherValuePx + (valuePx-otherValuePx)/(keyPx-otherKeyPx)*(intersectKeyPx-otherKeyPx);
22551 if (
mKeyAxis->orientation() == Qt::Horizontal)
22552 return QPointF(intersectKeyPx, intersectValuePx);
22554 return QPointF(intersectValuePx, intersectKeyPx);
22575 QVector<QPointF>
QCPCurve::getOptimizedCornerPoints(
int prevRegion,
int currentRegion,
double prevKey,
double prevValue,
double key,
double value,
double keyMin,
double valueMax,
double keyMax,
double valueMin)
const 22577 QVector<QPointF> result;
22578 switch (prevRegion)
22582 switch (currentRegion)
22591 if ((value-prevValue)/(key-prevKey)*(keyMin-key)+value < valueMin)
22602 switch (currentRegion)
22606 case 4: { result <<
coordsToPixels(keyMin, valueMax); result.append(result.last());
break; }
22607 case 6: { result <<
coordsToPixels(keyMin, valueMin); result.append(result.last());
break; }
22608 case 7: { result <<
coordsToPixels(keyMin, valueMax); result.append(result.last()); result <<
coordsToPixels(keyMax, valueMax);
break; }
22609 case 9: { result <<
coordsToPixels(keyMin, valueMin); result.append(result.last()); result <<
coordsToPixels(keyMax, valueMin);
break; }
22615 switch (currentRegion)
22624 if ((value-prevValue)/(key-prevKey)*(keyMax-key)+value < valueMin)
22635 switch (currentRegion)
22639 case 2: { result <<
coordsToPixels(keyMin, valueMax); result.append(result.last());
break; }
22640 case 8: { result <<
coordsToPixels(keyMax, valueMax); result.append(result.last());
break; }
22641 case 3: { result <<
coordsToPixels(keyMin, valueMax); result.append(result.last()); result <<
coordsToPixels(keyMin, valueMin);
break; }
22642 case 9: { result <<
coordsToPixels(keyMax, valueMax); result.append(result.last()); result <<
coordsToPixels(keyMax, valueMin);
break; }
22648 switch (currentRegion)
22659 switch (currentRegion)
22663 case 2: { result <<
coordsToPixels(keyMin, valueMin); result.append(result.last());
break; }
22664 case 8: { result <<
coordsToPixels(keyMax, valueMin); result.append(result.last());
break; }
22665 case 1: { result <<
coordsToPixels(keyMin, valueMin); result.append(result.last()); result <<
coordsToPixels(keyMin, valueMax);
break; }
22666 case 7: { result <<
coordsToPixels(keyMax, valueMin); result.append(result.last()); result <<
coordsToPixels(keyMax, valueMax);
break; }
22672 switch (currentRegion)
22681 if ((value-prevValue)/(key-prevKey)*(keyMax-key)+value < valueMin)
22692 switch (currentRegion)
22696 case 4: { result <<
coordsToPixels(keyMax, valueMax); result.append(result.last());
break; }
22697 case 6: { result <<
coordsToPixels(keyMax, valueMin); result.append(result.last());
break; }
22698 case 1: { result <<
coordsToPixels(keyMax, valueMax); result.append(result.last()); result <<
coordsToPixels(keyMin, valueMax);
break; }
22699 case 3: { result <<
coordsToPixels(keyMax, valueMin); result.append(result.last()); result <<
coordsToPixels(keyMin, valueMin);
break; }
22705 switch (currentRegion)
22714 if ((value-prevValue)/(key-prevKey)*(keyMin-key)+value < valueMin)
22741 switch (prevRegion)
22745 switch (currentRegion)
22750 case 3:
return false;
22751 default:
return true;
22756 switch (currentRegion)
22759 case 3:
return false;
22760 default:
return true;
22765 switch (currentRegion)
22770 case 9:
return false;
22771 default:
return true;
22776 switch (currentRegion)
22779 case 7:
return false;
22780 default:
return true;
22783 case 5:
return false;
22786 switch (currentRegion)
22789 case 9:
return false;
22790 default:
return true;
22795 switch (currentRegion)
22800 case 9:
return false;
22801 default:
return true;
22806 switch (currentRegion)
22809 case 9:
return false;
22810 default:
return true;
22815 switch (currentRegion)
22820 case 7:
return false;
22821 default:
return true;
22824 default:
return true;
22842 bool QCPCurve::getTraverse(
double prevKey,
double prevValue,
double key,
double value,
double keyMin,
double valueMax,
double keyMax,
double valueMin, QPointF &crossA, QPointF &crossB)
const 22849 QList<QPointF> intersections;
22850 const double valueMinPx =
mValueAxis->coordToPixel(valueMin);
22851 const double valueMaxPx =
mValueAxis->coordToPixel(valueMax);
22852 const double keyMinPx =
mKeyAxis->coordToPixel(keyMin);
22853 const double keyMaxPx =
mKeyAxis->coordToPixel(keyMax);
22854 const double keyPx =
mKeyAxis->coordToPixel(key);
22855 const double valuePx =
mValueAxis->coordToPixel(value);
22856 const double prevKeyPx =
mKeyAxis->coordToPixel(prevKey);
22857 const double prevValuePx =
mValueAxis->coordToPixel(prevValue);
22858 if (qFuzzyIsNull(key-prevKey))
22861 intersections.append(
mKeyAxis->orientation() == Qt::Horizontal ? QPointF(keyPx, valueMinPx) : QPointF(valueMinPx, keyPx));
22862 intersections.append(
mKeyAxis->orientation() == Qt::Horizontal ? QPointF(keyPx, valueMaxPx) : QPointF(valueMaxPx, keyPx));
22863 }
else if (qFuzzyIsNull(value-prevValue))
22866 intersections.append(
mKeyAxis->orientation() == Qt::Horizontal ? QPointF(keyMinPx, valuePx) : QPointF(valuePx, keyMinPx));
22867 intersections.append(
mKeyAxis->orientation() == Qt::Horizontal ? QPointF(keyMaxPx, valuePx) : QPointF(valuePx, keyMaxPx));
22871 double keyPerValuePx = (keyPx-prevKeyPx)/(valuePx-prevValuePx);
22873 gamma = prevKeyPx + (valueMaxPx-prevValuePx)*keyPerValuePx;
22874 if (gamma >= qMin(keyMinPx, keyMaxPx) && gamma <= qMax(keyMinPx, keyMaxPx))
22875 intersections.append(
mKeyAxis->orientation() == Qt::Horizontal ? QPointF(gamma, valueMaxPx) : QPointF(valueMaxPx, gamma));
22877 gamma = prevKeyPx + (valueMinPx-prevValuePx)*keyPerValuePx;
22878 if (gamma >= qMin(keyMinPx, keyMaxPx) && gamma <= qMax(keyMinPx, keyMaxPx))
22879 intersections.append(
mKeyAxis->orientation() == Qt::Horizontal ? QPointF(gamma, valueMinPx) : QPointF(valueMinPx, gamma));
22880 const double valuePerKeyPx = 1.0/keyPerValuePx;
22882 gamma = prevValuePx + (keyMinPx-prevKeyPx)*valuePerKeyPx;
22883 if (gamma >= qMin(valueMinPx, valueMaxPx) && gamma <= qMax(valueMinPx, valueMaxPx))
22884 intersections.append(
mKeyAxis->orientation() == Qt::Horizontal ? QPointF(keyMinPx, gamma) : QPointF(gamma, keyMinPx));
22886 gamma = prevValuePx + (keyMaxPx-prevKeyPx)*valuePerKeyPx;
22887 if (gamma >= qMin(valueMinPx, valueMaxPx) && gamma <= qMax(valueMinPx, valueMaxPx))
22888 intersections.append(
mKeyAxis->orientation() == Qt::Horizontal ? QPointF(keyMaxPx, gamma) : QPointF(gamma, keyMaxPx));
22892 if (intersections.size() > 2)
22895 double distSqrMax = 0;
22897 for (
int i=0; i<intersections.size()-1; ++i)
22899 for (
int k=i+1; k<intersections.size(); ++k)
22901 QPointF distPoint = intersections.at(i)-intersections.at(k);
22902 double distSqr = distPoint.x()*distPoint.x()+distPoint.y()+distPoint.y();
22903 if (distSqr > distSqrMax)
22905 pv1 = intersections.at(i);
22906 pv2 = intersections.at(k);
22907 distSqrMax = distSqr;
22911 intersections = QList<QPointF>() << pv1 << pv2;
22912 }
else if (intersections.size() != 2)
22919 double xDelta = keyPx-prevKeyPx;
22920 double yDelta = valuePx-prevValuePx;
22921 if (
mKeyAxis->orientation() != Qt::Horizontal)
22922 qSwap(xDelta, yDelta);
22923 if (xDelta*(intersections.at(1).x()-intersections.at(0).x()) + yDelta*(intersections.at(1).y()-intersections.at(0).y()) < 0)
22924 intersections.move(0, 1);
22925 crossA = intersections.at(0);
22926 crossB = intersections.at(1);
22955 void QCPCurve::getTraverseCornerPoints(
int prevRegion,
int currentRegion,
double keyMin,
double valueMax,
double keyMax,
double valueMin, QVector<QPointF> &beforeTraverse, QVector<QPointF> &afterTraverse)
const 22957 switch (prevRegion)
22961 switch (currentRegion)
22963 case 6: { beforeTraverse <<
coordsToPixels(keyMin, valueMax);
break; }
22965 case 8: { beforeTraverse <<
coordsToPixels(keyMin, valueMax);
break; }
22971 switch (currentRegion)
22973 case 7: { afterTraverse <<
coordsToPixels(keyMax, valueMax);
break; }
22974 case 9: { afterTraverse <<
coordsToPixels(keyMax, valueMin);
break; }
22980 switch (currentRegion)
22982 case 4: { beforeTraverse <<
coordsToPixels(keyMin, valueMin);
break; }
22984 case 8: { beforeTraverse <<
coordsToPixels(keyMin, valueMin);
break; }
22990 switch (currentRegion)
22992 case 3: { afterTraverse <<
coordsToPixels(keyMin, valueMin);
break; }
22993 case 9: { afterTraverse <<
coordsToPixels(keyMax, valueMin);
break; }
23000 switch (currentRegion)
23002 case 1: { afterTraverse <<
coordsToPixels(keyMin, valueMax);
break; }
23003 case 7: { afterTraverse <<
coordsToPixels(keyMax, valueMax);
break; }
23009 switch (currentRegion)
23011 case 2: { beforeTraverse <<
coordsToPixels(keyMax, valueMax);
break; }
23013 case 6: { beforeTraverse <<
coordsToPixels(keyMax, valueMax);
break; }
23019 switch (currentRegion)
23021 case 1: { afterTraverse <<
coordsToPixels(keyMin, valueMax);
break; }
23022 case 3: { afterTraverse <<
coordsToPixels(keyMin, valueMin);
break; }
23028 switch (currentRegion)
23030 case 2: { beforeTraverse <<
coordsToPixels(keyMax, valueMin);
break; }
23032 case 4: { beforeTraverse <<
coordsToPixels(keyMax, valueMin);
break; }
23067 double minDistSqr = std::numeric_limits<double>::max();
23074 if (currentDistSqr < minDistSqr)
23076 minDistSqr = currentDistSqr;
23084 QVector<QPointF> lines;
23086 for (
int i=0; i<lines.size()-1; ++i)
23089 if (currentDistSqr < minDistSqr)
23090 minDistSqr = currentDistSqr;
23094 return qSqrt(minDistSqr);
23175 QObject(parentPlot),
23177 mSpacingType(stAbsolute),
23218 if (index >= 0 && index <
mBars.size())
23220 return mBars.at(index);
23223 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << index;
23249 qDebug() << Q_FUNC_INFO <<
"bars is 0";
23253 if (!
mBars.contains(bars))
23256 qDebug() << Q_FUNC_INFO <<
"bars plottable is already in this bars group:" <<
reinterpret_cast<quintptr
>(
bars);
23272 qDebug() << Q_FUNC_INFO <<
"bars is 0";
23277 if (!
mBars.contains(bars))
23292 qDebug() << Q_FUNC_INFO <<
"bars is 0";
23296 if (
mBars.contains(bars))
23299 qDebug() << Q_FUNC_INFO <<
"bars plottable is not in this bars group:" <<
reinterpret_cast<quintptr
>(
bars);
23311 if (!
mBars.contains(bars))
23312 mBars.append(bars);
23324 mBars.removeOne(bars);
23336 QList<const QCPBars*> baseBars;
23341 if (!baseBars.contains(b))
23342 baseBars.append(b);
23351 int index = baseBars.indexOf(thisBase);
23354 if (baseBars.size() % 2 == 1 && index == (baseBars.size()-1)/2)
23359 double lowerPixelWidth, upperPixelWidth;
23361 int dir = (index <= (baseBars.size()-1)/2) ? -1 : 1;
23362 if (baseBars.size() % 2 == 0)
23364 startIndex = baseBars.size()/2 + (dir < 0 ? -1 : 0);
23368 startIndex = (baseBars.size()-1)/2+dir;
23369 baseBars.at((baseBars.size()-1)/2)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth);
23370 result += qAbs(upperPixelWidth-lowerPixelWidth)*0.5;
23371 result +=
getPixelSpacing(baseBars.at((baseBars.size()-1)/2), keyCoord);
23373 for (
int i = startIndex; i != index; i += dir)
23375 baseBars.at(i)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth);
23376 result += qAbs(upperPixelWidth-lowerPixelWidth);
23380 baseBars.at(index)->getPixelWidth(keyCoord, lowerPixelWidth, upperPixelWidth);
23381 result += qAbs(upperPixelWidth-lowerPixelWidth)*0.5;
23591 mWidthType(wtPlotCoords),
23597 mPen.setColor(Qt::blue);
23598 mPen.setStyle(Qt::SolidLine);
23599 mBrush.setColor(QColor(40, 50, 255, 30));
23600 mBrush.setStyle(Qt::SolidPattern);
23642 void QCPBars::setData(
const QVector<double> &keys,
const QVector<double> &values,
bool alreadySorted)
23645 addData(keys, values, alreadySorted);
23728 void QCPBars::addData(
const QVector<double> &keys,
const QVector<double> &values,
bool alreadySorted)
23730 if (keys.size() != values.size())
23731 qDebug() << Q_FUNC_INFO <<
"keys and values have different sizes:" << keys.size() << values.size();
23732 const int n = qMin(keys.size(), values.size());
23733 QVector<QCPBarsData> tempData(n);
23734 QVector<QCPBarsData>::iterator it = tempData.begin();
23735 const QVector<QCPBarsData>::iterator itEnd = tempData.end();
23737 while (it != itEnd)
23740 it->value = values[i];
23774 if (bars ==
this)
return;
23777 qDebug() << Q_FUNC_INFO <<
"passed QCPBars* doesn't have same key and value axis as this QCPBars";
23807 if (bars ==
this)
return;
23810 qDebug() << Q_FUNC_INFO <<
"passed QCPBars* doesn't have same key and value axis as this QCPBars";
23840 if (rect.intersects(
getBarRect(it->key, it->value)))
23856 if (
mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint()))
23863 if (
getBarRect(it->key, it->value).contains(pos))
23895 double lowerPixelWidth, upperPixelWidth, keyPixel;
23898 keyPixel =
mKeyAxis.data()->coordToPixel(range.
lower) + lowerPixelWidth;
23901 const double lowerCorrected =
mKeyAxis.data()->pixelToCoord(keyPixel);
23902 if (!qIsNaN(lowerCorrected) && qIsFinite(lowerCorrected) && range.
lower > lowerCorrected)
23903 range.
lower = lowerCorrected;
23906 keyPixel =
mKeyAxis.data()->coordToPixel(range.
upper) + upperPixelWidth;
23909 const double upperCorrected =
mKeyAxis.data()->pixelToCoord(keyPixel);
23910 if (!qIsNaN(upperCorrected) && qIsFinite(upperCorrected) && range.
upper < upperCorrected)
23911 range.
upper = upperCorrected;
23924 bool haveLower =
true;
23925 bool haveUpper =
true;
23936 if (qIsNaN(current))
continue;
23939 if (current < range.
lower || !haveLower)
23941 range.
lower = current;
23944 if (current > range.
upper || !haveUpper)
23946 range.
upper = current;
23959 if (index >= 0 && index < mDataContainer->size())
23963 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QPointF(); }
23969 return QPointF(keyPixel, valuePixel);
23971 return QPointF(valuePixel, keyPixel);
23974 qDebug() << Q_FUNC_INFO <<
"Index out of bounds" << index;
23982 if (!
mKeyAxis || !
mValueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
23989 QList<QCPDataRange> selectedSegments, unselectedSegments, allSegments;
23991 allSegments << unselectedSegments << selectedSegments;
23992 for (
int i=0; i<allSegments.size(); ++i)
23994 bool isSelectedSegment = i >= unselectedSegments.size();
23997 mDataContainer->limitIteratorsToDataRange(begin, end, allSegments.at(i));
24004 #ifdef QCUSTOMPLOT_CHECK_DATA 24006 qDebug() << Q_FUNC_INFO <<
"Data point at" << it->key <<
"of drawn range invalid." <<
"Plottable name:" <<
name();
24015 painter->setBrush(
mBrush);
24019 painter->drawPolygon(
getBarRect(it->key, it->value));
24033 painter->setBrush(
mBrush);
24035 QRectF r = QRectF(0, 0, rect.width()*0.67, rect.height()*0.67);
24036 r.moveCenter(rect.center());
24037 painter->drawRect(r);
24058 qDebug() << Q_FUNC_INFO <<
"invalid key axis";
24073 double lowerPixelBound =
mKeyAxis.data()->coordToPixel(
mKeyAxis.data()->range().lower);
24074 double upperPixelBound =
mKeyAxis.data()->coordToPixel(
mKeyAxis.data()->range().upper);
24075 bool isVisible =
false;
24081 const QRectF barRect =
getBarRect(it->key, it->value);
24082 if (
mKeyAxis.data()->orientation() == Qt::Horizontal)
24083 isVisible = ((!
mKeyAxis.data()->rangeReversed() && barRect.right() >= lowerPixelBound) || (
mKeyAxis.data()->rangeReversed() && barRect.left() <= lowerPixelBound));
24085 isVisible = ((!
mKeyAxis.data()->rangeReversed() && barRect.top() <= lowerPixelBound) || (
mKeyAxis.data()->rangeReversed() && barRect.bottom() >= lowerPixelBound));
24095 const QRectF barRect =
getBarRect(it->key, it->value);
24096 if (
mKeyAxis.data()->orientation() == Qt::Horizontal)
24097 isVisible = ((!
mKeyAxis.data()->rangeReversed() && barRect.left() <= upperPixelBound) || (
mKeyAxis.data()->rangeReversed() && barRect.right() >= upperPixelBound));
24099 isVisible = ((!
mKeyAxis.data()->rangeReversed() && barRect.bottom() >= upperPixelBound) || (
mKeyAxis.data()->rangeReversed() && barRect.top() <= upperPixelBound));
24118 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QRectF(); }
24120 double lowerPixelWidth, upperPixelWidth;
24124 double valuePixel = valueAxis->
coordToPixel(base+value);
24128 double bottomOffset = (
mBarBelow &&
mPen != Qt::NoPen ? 1 : 0)*(
mPen.isCosmetic() ? 1 :
mPen.widthF());
24131 if (qAbs(valuePixel-basePixel) <= qAbs(bottomOffset))
24132 bottomOffset = valuePixel-basePixel;
24135 return QRectF(QPointF(keyPixel+lowerPixelWidth, valuePixel), QPointF(keyPixel+upperPixelWidth, basePixel+bottomOffset)).normalized();
24138 return QRectF(QPointF(basePixel+bottomOffset, keyPixel+lowerPixelWidth), QPointF(valuePixel, keyPixel+upperPixelWidth)).normalized();
24167 if (
mKeyAxis.data()->orientation() == Qt::Horizontal)
24173 qDebug() << Q_FUNC_INFO <<
"No key axis or axis rect defined";
24180 double keyPixel =
mKeyAxis.data()->coordToPixel(key);
24186 qDebug() << Q_FUNC_INFO <<
"No key axis defined";
24207 double epsilon = qAbs(key)*(
sizeof(key)==4 ? 1e-6 : 1e-14);
24209 epsilon = (
sizeof(key)==4 ? 1e-6 : 1e-14);
24212 while (it != itEnd)
24214 if (it->key > key-epsilon && it->key < key+epsilon)
24216 if ((positive && it->value > max) ||
24217 (!positive && it->value < max))
24223 return max +
mBarBelow.data()->getStackedBaseValue(key, positive);
24238 if (!lower && !upper)
return;
24244 upper->
mBarBelow.data()->mBarAbove = 0;
24250 lower->
mBarAbove.data()->mBarBelow = 0;
24256 lower->
mBarAbove.data()->mBarBelow = 0;
24259 upper->
mBarBelow.data()->mBarAbove = 0;
24383 lowerQuartile(lowerQuartile),
24385 upperQuartile(upperQuartile),
24468 mWhiskerWidth(0.2),
24469 mWhiskerPen(Qt::black, 0, Qt::DashLine, Qt::FlatCap),
24470 mWhiskerBarPen(Qt::black),
24471 mWhiskerAntialiased(false),
24472 mMedianPen(Qt::black, 3, Qt::SolidLine, Qt::FlatCap),
24475 setPen(QPen(Qt::black));
24510 void QCPStatisticalBox::setData(
const QVector<double> &keys,
const QVector<double> &minimum,
const QVector<double> &lowerQuartile,
const QVector<double> &median,
const QVector<double> &upperQuartile,
const QVector<double> &maximum,
bool alreadySorted)
24513 addData(keys, minimum, lowerQuartile, median, upperQuartile, maximum, alreadySorted);
24611 void QCPStatisticalBox::addData(
const QVector<double> &keys,
const QVector<double> &minimum,
const QVector<double> &lowerQuartile,
const QVector<double> &median,
const QVector<double> &upperQuartile,
const QVector<double> &maximum,
bool alreadySorted)
24613 if (keys.size() != minimum.size() || minimum.size() != lowerQuartile.size() || lowerQuartile.size() != median.size() ||
24614 median.size() != upperQuartile.size() || upperQuartile.size() != maximum.size() || maximum.size() != keys.size())
24615 qDebug() << Q_FUNC_INFO <<
"keys, minimum, lowerQuartile, median, upperQuartile, maximum have different sizes:" 24616 << keys.size() << minimum.size() << lowerQuartile.size() << median.size() << upperQuartile.size() << maximum.size();
24617 const int n = qMin(keys.size(), qMin(minimum.size(), qMin(lowerQuartile.size(), qMin(median.size(), qMin(upperQuartile.size(), maximum.size())))));
24618 QVector<QCPStatisticalBoxData> tempData(n);
24619 QVector<QCPStatisticalBoxData>::iterator it = tempData.begin();
24620 const QVector<QCPStatisticalBoxData>::iterator itEnd = tempData.end();
24622 while (it != itEnd)
24625 it->minimum = minimum[i];
24626 it->lowerQuartile = lowerQuartile[i];
24627 it->median = median[i];
24628 it->upperQuartile = upperQuartile[i];
24629 it->maximum = maximum[i];
24644 void QCPStatisticalBox::addData(
double key,
double minimum,
double lowerQuartile,
double median,
double upperQuartile,
double maximum,
const QVector<double> &outliers)
24681 if (
mKeyAxis->axisRect()->rect().contains(pos.toPoint()))
24687 double minDistSqr = std::numeric_limits<double>::max();
24693 if (currentDistSqr < minDistSqr)
24695 minDistSqr = currentDistSqr;
24696 closestDataPoint = it;
24701 for (
int i=0; i<whiskerBackbones.size(); ++i)
24704 if (currentDistSqr < minDistSqr)
24706 minDistSqr = currentDistSqr;
24707 closestDataPoint = it;
24717 return qSqrt(minDistSqr);
24740 return mDataContainer->valueRange(foundRange, inSignDomain, inKeyRange);
24749 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
24755 QList<QCPDataRange> selectedSegments, unselectedSegments, allSegments;
24757 allSegments << unselectedSegments << selectedSegments;
24758 for (
int i=0; i<allSegments.size(); ++i)
24760 bool isSelectedSegment = i >= unselectedSegments.size();
24763 mDataContainer->limitIteratorsToDataRange(begin, end, allSegments.at(i));
24770 # ifdef QCUSTOMPLOT_CHECK_DATA 24774 qDebug() << Q_FUNC_INFO <<
"Data point at" << it->key <<
"of drawn range has invalid data." <<
"Plottable name:" <<
name();
24775 for (
int i=0; i<it->outliers.size(); ++i)
24777 qDebug() << Q_FUNC_INFO <<
"Data point outlier at" << it->key <<
"of drawn range invalid." <<
"Plottable name:" <<
name();
24787 painter->setBrush(
mBrush);
24807 painter->setBrush(
mBrush);
24808 QRectF r = QRectF(0, 0, rect.width()*0.67, rect.height()*0.67);
24809 r.moveCenter(rect.center());
24810 painter->drawRect(r);
24826 painter->drawRect(quartileBox);
24829 painter->setClipRect(quartileBox, Qt::IntersectClip);
24842 for (
int i=0; i<it->outliers.size(); ++i)
24864 qDebug() << Q_FUNC_INFO <<
"invalid key axis";
24898 QVector<QLineF> result(2);
24913 QVector<QLineF> result(2);
24981 mKeyRange(keyRange),
24982 mValueRange(valueRange),
24986 mDataModified(true)
25020 if (&other !=
this)
25047 if (keyCell >= 0 && keyCell < mKeySize && valueCell >= 0 && valueCell <
mValueSize)
25056 if (keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex <
mValueSize)
25072 if (
mAlpha && keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex <
mValueSize)
25101 #ifdef __EXCEPTIONS 25105 #ifdef __EXCEPTIONS 25106 }
catch (...) {
mData = 0; }
25111 qDebug() << Q_FUNC_INFO <<
"out of memory for data dimensions "<<
mKeySize <<
"*" <<
mValueSize;
25214 if (keyCell >= 0 && keyCell < mKeySize && valueCell >= 0 && valueCell <
mValueSize)
25238 if (keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex <
mValueSize)
25247 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << keyIndex << valueIndex;
25267 if (keyIndex >= 0 && keyIndex < mKeySize && valueIndex >= 0 && valueIndex <
mValueSize)
25275 qDebug() << Q_FUNC_INFO <<
"index out of bounds:" << keyIndex << valueIndex;
25295 double minHeight =
mData[0];
25296 double maxHeight =
mData[0];
25298 for (
int i=0; i<dataCount; ++i)
25300 if (
mData[i] > maxHeight)
25301 maxHeight =
mData[i];
25302 if (
mData[i] < minHeight)
25303 minHeight =
mData[i];
25339 for (
int i=0; i<dataCount; ++i)
25359 for (
int i=0; i<dataCount; ++i)
25432 #ifdef __EXCEPTIONS 25436 #ifdef __EXCEPTIONS 25437 }
catch (...) {
mAlpha = 0; }
25441 if (initializeOpaque)
25446 qDebug() << Q_FUNC_INFO <<
"out of memory for data dimensions "<<
mKeySize <<
"*" <<
mValueSize;
25577 mDataScaleType(
QCPAxis::stLinear),
25580 mInterpolate(true),
25581 mTightBoundary(false),
25582 mMapImageInvalidated(true)
25602 qDebug() << Q_FUNC_INFO <<
"The data pointer is already in (and owned by) this plottable" <<
reinterpret_cast<quintptr
>(
data);
25766 if (recalculateDataBounds)
25794 mLegendIcon = QPixmap::fromImage(
mMapImage.mirrored(mirrorX, mirrorY)).scaled(thumbSize, Qt::KeepAspectRatio, transformMode);
25807 if (
mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint()))
25809 double posKey, posValue;
25831 else if (result.
lower <= 0 && result.
upper <= 0)
25832 foundRange =
false;
25837 else if (result.
upper >= 0 && result.
lower >= 0)
25838 foundRange =
false;
25850 foundRange =
false;
25862 else if (result.
lower <= 0 && result.
upper <= 0)
25863 foundRange =
false;
25868 else if (result.
upper >= 0 && result.
lower >= 0)
25869 foundRange =
false;
25891 if (!keyAxis)
return;
25894 const QImage::Format format = QImage::Format_ARGB32_Premultiplied;
25897 int keyOversamplingFactor =
mInterpolate ? 1 : (int)(1.0+100.0/(
double)keySize);
25898 int valueOversamplingFactor =
mInterpolate ? 1 : (int)(1.0+100.0/(
double)valueSize);
25901 if (keyAxis->
orientation() == Qt::Horizontal && (
mMapImage.width() != keySize*keyOversamplingFactor ||
mMapImage.height() != valueSize*valueOversamplingFactor))
25902 mMapImage = QImage(QSize(keySize*keyOversamplingFactor, valueSize*valueOversamplingFactor), format);
25903 else if (keyAxis->
orientation() == Qt::Vertical && (
mMapImage.width() != valueSize*valueOversamplingFactor ||
mMapImage.height() != keySize*keyOversamplingFactor))
25904 mMapImage = QImage(QSize(valueSize*valueOversamplingFactor, keySize*keyOversamplingFactor), format);
25908 qDebug() << Q_FUNC_INFO <<
"Couldn't create map image (possibly too large for memory)";
25909 mMapImage = QImage(QSize(10, 10), format);
25914 if (keyOversamplingFactor > 1 || valueOversamplingFactor > 1)
25929 const int lineCount = valueSize;
25930 const int rowCount = keySize;
25931 for (
int line=0; line<lineCount; ++line)
25933 QRgb* pixels =
reinterpret_cast<QRgb*
>(localMapImage->scanLine(lineCount-1-line));
25941 const int lineCount = keySize;
25942 const int rowCount = valueSize;
25943 for (
int line=0; line<lineCount; ++line)
25945 QRgb* pixels =
reinterpret_cast<QRgb*
>(localMapImage->scanLine(lineCount-1-line));
25953 if (keyOversamplingFactor > 1 || valueOversamplingFactor > 1)
25956 mMapImage =
mUndersampledMapImage.scaled(keySize*keyOversamplingFactor, valueSize*valueOversamplingFactor, Qt::IgnoreAspectRatio, Qt::FastTransformation);
25958 mMapImage =
mUndersampledMapImage.scaled(valueSize*valueOversamplingFactor, keySize*keyOversamplingFactor, Qt::IgnoreAspectRatio, Qt::FastTransformation);
25978 QRectF mapBufferTarget;
25982 const double mapBufferPixelRatio = 3;
25983 mapBufferTarget = painter->clipRegion().boundingRect();
25984 mapBuffer = QPixmap((mapBufferTarget.size()*mapBufferPixelRatio).toSize());
25985 mapBuffer.fill(Qt::transparent);
25987 localPainter->scale(mapBufferPixelRatio, mapBufferPixelRatio);
25988 localPainter->translate(-mapBufferTarget.topLeft());
25994 double halfCellWidth = 0;
25995 double halfCellHeight = 0;
25996 if (
keyAxis()->orientation() == Qt::Horizontal)
25999 halfCellWidth = 0.5*imageRect.width()/(double)(
mMapData->
keySize()-1);
26005 halfCellHeight = 0.5*imageRect.height()/(double)(
mMapData->
keySize()-1);
26009 imageRect.adjust(-halfCellWidth, -halfCellHeight, halfCellWidth, halfCellHeight);
26012 const bool smoothBackup = localPainter->renderHints().testFlag(QPainter::SmoothPixmapTransform);
26013 localPainter->setRenderHint(QPainter::SmoothPixmapTransform,
mInterpolate);
26014 QRegion clipBackup;
26017 clipBackup = localPainter->clipRegion();
26020 localPainter->setClipRect(tightClipRect, Qt::IntersectClip);
26022 localPainter->drawImage(imageRect,
mMapImage.mirrored(mirrorX, mirrorY));
26024 localPainter->setClipRegion(clipBackup);
26025 localPainter->setRenderHint(QPainter::SmoothPixmapTransform, smoothBackup);
26029 delete localPainter;
26030 painter->drawPixmap(mapBufferTarget.toRect(), mapBuffer);
26041 QPixmap scaledIcon =
mLegendIcon.scaled(rect.size().toSize(), Qt::KeepAspectRatio, Qt::FastTransformation);
26042 QRectF iconRect = QRectF(0, 0, scaledIcon.width(), scaledIcon.height());
26043 iconRect.moveCenter(rect.center());
26044 painter->drawPixmap(iconRect.topLeft(), scaledIcon);
26234 mChartStyle(csCandlestick),
26236 mWidthType(wtPlotCoords),
26238 mBrushPositive(QBrush(QColor(50, 160, 0))),
26239 mBrushNegative(QBrush(QColor(180, 0, 15))),
26240 mPenPositive(QPen(QColor(40, 150, 0))),
26241 mPenNegative(QPen(QColor(170, 5, 5)))
26281 void QCPFinancial::setData(
const QVector<double> &keys,
const QVector<double> &open,
const QVector<double> &high,
const QVector<double> &low,
const QVector<double> &close,
bool alreadySorted)
26284 addData(keys, open, high, low, close, alreadySorted);
26402 void QCPFinancial::addData(
const QVector<double> &keys,
const QVector<double> &open,
const QVector<double> &high,
const QVector<double> &low,
const QVector<double> &close,
bool alreadySorted)
26404 if (keys.size() != open.size() || open.size() != high.size() || high.size() != low.size() || low.size() != close.size() || close.size() != keys.size())
26405 qDebug() << Q_FUNC_INFO <<
"keys, open, high, low, close have different sizes:" << keys.size() << open.size() << high.size() << low.size() << close.size();
26406 const int n = qMin(keys.size(), qMin(open.size(), qMin(high.size(), qMin(low.size(), close.size()))));
26407 QVector<QCPFinancialData> tempData(n);
26408 QVector<QCPFinancialData>::iterator it = tempData.begin();
26409 const QVector<QCPFinancialData>::iterator itEnd = tempData.end();
26411 while (it != itEnd)
26414 it->open = open[i];
26415 it->high = high[i];
26417 it->close = close[i];
26471 if (
mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint()))
26478 double result = -1;
26482 result =
ohlcSelectTest(pos, visibleBegin, visibleEnd, closestDataPoint);
break;
26515 return mDataContainer->valueRange(foundRange, inSignDomain, inKeyRange);
26535 int count = qMin(time.size(), value.size());
26539 QCPFinancialData currentBinData(0, value.first(), value.first(), value.first(), value.first());
26540 int currentBinIndex = qFloor((time.first()-timeBinOffset)/timeBinSize+0.5);
26541 for (
int i=0; i<count; ++i)
26543 int index = qFloor((time.at(i)-timeBinOffset)/timeBinSize+0.5);
26544 if (currentBinIndex == index)
26546 if (value.at(i) < currentBinData.low) currentBinData.low = value.at(i);
26547 if (value.at(i) > currentBinData.high) currentBinData.high = value.at(i);
26550 currentBinData.close = value.at(i);
26551 currentBinData.key = timeBinOffset+(index)*timeBinSize;
26552 data.
add(currentBinData);
26557 currentBinData.close = value.at(i-1);
26558 currentBinData.key = timeBinOffset+(index-1)*timeBinSize;
26559 data.
add(currentBinData);
26561 currentBinIndex = index;
26562 currentBinData.open = value.at(i);
26563 currentBinData.high = value.at(i);
26564 currentBinData.low = value.at(i);
26579 QList<QCPDataRange> selectedSegments, unselectedSegments, allSegments;
26581 allSegments << unselectedSegments << selectedSegments;
26582 for (
int i=0; i<allSegments.size(); ++i)
26584 bool isSelectedSegment = i >= unselectedSegments.size();
26587 mDataContainer->limitIteratorsToDataRange(begin, end, allSegments.at(i));
26595 drawOhlcPlot(painter, begin, end, isSelectedSegment);
break;
26617 painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.topLeft().toPoint()));
26618 painter->
drawLine(QLineF(0, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft()));
26619 painter->
drawLine(QLineF(rect.width()*0.2, rect.height()*0.3, rect.width()*0.2, rect.height()*0.5).translated(rect.topLeft()));
26620 painter->
drawLine(QLineF(rect.width()*0.8, rect.height()*0.5, rect.width()*0.8, rect.height()*0.7).translated(rect.topLeft()));
26624 painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.bottomRight().toPoint()));
26625 painter->
drawLine(QLineF(0, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft()));
26626 painter->
drawLine(QLineF(rect.width()*0.2, rect.height()*0.3, rect.width()*0.2, rect.height()*0.5).translated(rect.topLeft()));
26627 painter->
drawLine(QLineF(rect.width()*0.8, rect.height()*0.5, rect.width()*0.8, rect.height()*0.7).translated(rect.topLeft()));
26630 painter->setBrush(
mBrush);
26632 painter->
drawLine(QLineF(0, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft()));
26633 painter->
drawLine(QLineF(rect.width()*0.2, rect.height()*0.3, rect.width()*0.2, rect.height()*0.5).translated(rect.topLeft()));
26634 painter->
drawLine(QLineF(rect.width()*0.8, rect.height()*0.5, rect.width()*0.8, rect.height()*0.7).translated(rect.topLeft()));
26643 painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.topLeft().toPoint()));
26644 painter->
drawLine(QLineF(0, rect.height()*0.5, rect.width()*0.25, rect.height()*0.5).translated(rect.topLeft()));
26645 painter->
drawLine(QLineF(rect.width()*0.75, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft()));
26646 painter->drawRect(QRectF(rect.width()*0.25, rect.height()*0.25, rect.width()*0.5, rect.height()*0.5).translated(rect.topLeft()));
26650 painter->setClipRegion(QRegion(QPolygon() << rect.bottomLeft().toPoint() << rect.topRight().toPoint() << rect.bottomRight().toPoint()));
26651 painter->
drawLine(QLineF(0, rect.height()*0.5, rect.width()*0.25, rect.height()*0.5).translated(rect.topLeft()));
26652 painter->
drawLine(QLineF(rect.width()*0.75, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft()));
26653 painter->drawRect(QRectF(rect.width()*0.25, rect.height()*0.25, rect.width()*0.5, rect.height()*0.5).translated(rect.topLeft()));
26656 painter->setBrush(
mBrush);
26658 painter->
drawLine(QLineF(0, rect.height()*0.5, rect.width()*0.25, rect.height()*0.5).translated(rect.topLeft()));
26659 painter->
drawLine(QLineF(rect.width()*0.75, rect.height()*0.5, rect.width(), rect.height()*0.5).translated(rect.topLeft()));
26660 painter->drawRect(QRectF(rect.width()*0.25, rect.height()*0.25, rect.width()*0.5, rect.height()*0.5).translated(rect.topLeft()));
26675 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
26689 double closePixel = valueAxis->
coordToPixel(it->close);
26694 painter->
drawLine(QPointF(keyPixel-pixelWidth, openPixel), QPointF(keyPixel, openPixel));
26696 painter->
drawLine(QPointF(keyPixel, closePixel), QPointF(keyPixel+pixelWidth, closePixel));
26710 double closePixel = valueAxis->
coordToPixel(it->close);
26715 painter->
drawLine(QPointF(openPixel, keyPixel-pixelWidth), QPointF(openPixel, keyPixel));
26717 painter->
drawLine(QPointF(closePixel, keyPixel), QPointF(closePixel, keyPixel+pixelWidth));
26732 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
26749 painter->setBrush(
mBrush);
26753 double closePixel = valueAxis->
coordToPixel(it->close);
26760 painter->drawRect(QRectF(QPointF(keyPixel-pixelWidth, closePixel), QPointF(keyPixel+pixelWidth, openPixel)));
26777 painter->setBrush(
mBrush);
26781 double closePixel = valueAxis->
coordToPixel(it->close);
26788 painter->drawRect(QRectF(QPointF(closePixel, keyPixel-pixelWidth), QPointF(openPixel, keyPixel+pixelWidth)));
26820 if (
mKeyAxis.data()->orientation() == Qt::Horizontal)
26825 qDebug() << Q_FUNC_INFO <<
"No key axis or axis rect defined";
26831 result =
mKeyAxis.data()->coordToPixel(key+
mWidth*0.5)-keyPixel;
26833 qDebug() << Q_FUNC_INFO <<
"No key axis defined";
26853 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return -1; }
26855 double minDistSqr = std::numeric_limits<double>::max();
26863 if (currentDistSqr < minDistSqr)
26865 minDistSqr = currentDistSqr;
26866 closestDataPoint = it;
26876 if (currentDistSqr < minDistSqr)
26878 minDistSqr = currentDistSqr;
26879 closestDataPoint = it;
26883 return qSqrt(minDistSqr);
26900 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return -1; }
26902 double minDistSqr = std::numeric_limits<double>::max();
26907 double currentDistSqr;
26910 QCPRange boxValueRange(it->close, it->open);
26911 double posKey, posValue;
26922 currentDistSqr = qMin(highLineDistSqr, lowLineDistSqr);
26924 if (currentDistSqr < minDistSqr)
26926 minDistSqr = currentDistSqr;
26927 closestDataPoint = it;
26934 double currentDistSqr;
26937 QCPRange boxValueRange(it->close, it->open);
26938 double posKey, posValue;
26949 currentDistSqr = qMin(highLineDistSqr, lowLineDistSqr);
26951 if (currentDistSqr < minDistSqr)
26953 minDistSqr = currentDistSqr;
26954 closestDataPoint = it;
26958 return qSqrt(minDistSqr);
26979 qDebug() << Q_FUNC_INFO <<
"invalid key axis";
26997 if (!keyAxis || !valueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return QRectF(); }
27004 return QRectF(keyPixel-keyWidthPixels, highPixel, keyWidthPixels*2, lowPixel-highPixel).normalized();
27006 return QRectF(highPixel, keyPixel-keyWidthPixels, lowPixel-highPixel, keyWidthPixels*2).normalized();
27056 errorMinus(errorMinus),
27057 errorPlus(errorPlus)
27122 mErrorType(etValueError),
27126 setPen(QPen(Qt::black, 0));
27185 addData(errorMinus, errorPlus);
27204 if (plottable && qobject_cast<QCPErrorBars*>(plottable))
27207 qDebug() << Q_FUNC_INFO <<
"can't set another QCPErrorBars instance as data plottable";
27213 qDebug() << Q_FUNC_INFO <<
"passed plottable doesn't implement 1d interface, can't associate with QCPErrorBars";
27274 if (errorMinus.size() != errorPlus.size())
27275 qDebug() << Q_FUNC_INFO <<
"minus and plus error vectors have different sizes:" << errorMinus.size() << errorPlus.size();
27276 const int n = qMin(errorMinus.size(), errorPlus.size());
27278 for (
int i=0; i<n; ++i)
27323 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27333 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27343 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27352 const double value =
mDataPlottable->interface1D()->dataMainValue(index);
27359 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27370 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27382 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27400 QCPErrorBarsDataContainer::const_iterator visibleBegin, visibleEnd;
27403 QVector<QLineF> backbones, whiskers;
27404 for (QCPErrorBarsDataContainer::const_iterator it=visibleBegin; it!=visibleEnd; ++it)
27409 for (
int i=0; i<backbones.size(); ++i)
27429 int beginIndex =
mDataPlottable->interface1D()->findBegin(sortKey, expandedRange);
27434 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27445 int endIndex =
mDataPlottable->interface1D()->findEnd(sortKey, expandedRange);
27450 qDebug() << Q_FUNC_INFO <<
"no data plottable set";
27464 if (
mKeyAxis.data()->axisRect()->rect().contains(pos.toPoint()))
27466 QCPErrorBarsDataContainer::const_iterator closestDataPoint =
mDataContainer->constEnd();
27482 if (!
mKeyAxis || !
mValueAxis) { qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
return; }
27487 bool checkPointVisibility = !
mDataPlottable->interface1D()->sortKeyIsMainKey();
27490 #ifdef QCUSTOMPLOT_CHECK_DATA 27491 QCPErrorBarsDataContainer::const_iterator it;
27495 qDebug() << Q_FUNC_INFO <<
"Data point at index" << it-
mDataContainer->constBegin() <<
"invalid." <<
"Plottable name:" <<
name();
27500 painter->setBrush(Qt::NoBrush);
27502 QList<QCPDataRange> selectedSegments, unselectedSegments, allSegments;
27504 allSegments << unselectedSegments << selectedSegments;
27505 QVector<QLineF> backbones, whiskers;
27506 for (
int i=0; i<allSegments.size(); ++i)
27508 QCPErrorBarsDataContainer::const_iterator begin, end;
27513 bool isSelectedSegment = i >= unselectedSegments.size();
27518 if (painter->pen().capStyle() == Qt::SquareCap)
27520 QPen capFixPen(painter->pen());
27521 capFixPen.setCapStyle(Qt::FlatCap);
27522 painter->
setPen(capFixPen);
27526 for (QCPErrorBarsDataContainer::const_iterator it=begin; it!=end; ++it)
27531 painter->drawLines(backbones);
27532 painter->drawLines(whiskers);
27547 painter->
drawLine(QLineF(rect.center().x(), rect.top()+2, rect.center().x(), rect.bottom()-1));
27548 painter->
drawLine(QLineF(rect.center().x()-4, rect.top()+2, rect.center().x()+4, rect.top()+2));
27549 painter->
drawLine(QLineF(rect.center().x()-4, rect.bottom()-1, rect.center().x()+4, rect.bottom()-1));
27552 painter->
drawLine(QLineF(rect.left()+2, rect.center().y(), rect.right()-2, rect.center().y()));
27553 painter->
drawLine(QLineF(rect.left()+2, rect.center().y()-4, rect.left()+2, rect.center().y()+4));
27554 painter->
drawLine(QLineF(rect.right()-2, rect.center().y()-4, rect.right()-2, rect.center().y()+4));
27563 foundRange =
false;
27568 bool haveLower =
false;
27569 bool haveUpper =
false;
27570 QCPErrorBarsDataContainer::const_iterator it;
27577 if (qIsNaN(current))
continue;
27580 if (current < range.
lower || !haveLower)
27582 range.
lower = current;
27585 if (current > range.
upper || !haveUpper)
27587 range.
upper = current;
27594 if (qIsNaN(dataKey))
continue;
27596 double current = dataKey + (qIsNaN(it->errorPlus) ? 0 : it->errorPlus);
27599 if (current > range.
upper || !haveUpper)
27601 range.
upper = current;
27606 current = dataKey - (qIsNaN(it->errorMinus) ? 0 : it->errorMinus);
27609 if (current < range.
lower || !haveLower)
27611 range.
lower = current;
27618 if (haveUpper && !haveLower)
27622 }
else if (haveLower && !haveUpper)
27628 foundRange = haveLower && haveUpper;
27637 foundRange =
false;
27642 const bool restrictKeyRange = inKeyRange !=
QCPRange();
27643 bool haveLower =
false;
27644 bool haveUpper =
false;
27645 QCPErrorBarsDataContainer::const_iterator itBegin =
mDataContainer->constBegin();
27646 QCPErrorBarsDataContainer::const_iterator itEnd =
mDataContainer->constEnd();
27647 if (
mDataPlottable->interface1D()->sortKeyIsMainKey() && restrictKeyRange)
27652 for (QCPErrorBarsDataContainer::const_iterator it = itBegin; it != itEnd; ++it)
27654 if (restrictKeyRange)
27657 if (dataKey < inKeyRange.lower || dataKey > inKeyRange.
upper)
27663 if (qIsNaN(dataValue))
continue;
27665 double current = dataValue + (qIsNaN(it->errorPlus) ? 0 : it->errorPlus);
27668 if (current > range.
upper || !haveUpper)
27670 range.
upper = current;
27675 current = dataValue - (qIsNaN(it->errorMinus) ? 0 : it->errorMinus);
27678 if (current < range.
lower || !haveLower)
27680 range.
lower = current;
27688 if (qIsNaN(current))
continue;
27691 if (current < range.
lower || !haveLower)
27693 range.
lower = current;
27696 if (current > range.
upper || !haveUpper)
27698 range.
upper = current;
27705 if (haveUpper && !haveLower)
27709 }
else if (haveLower && !haveUpper)
27715 foundRange = haveLower && haveUpper;
27735 QPointF centerPixel =
mDataPlottable->interface1D()->dataPixelPosition(index);
27736 if (qIsNaN(centerPixel.x()) || qIsNaN(centerPixel.y()))
27740 const double centerErrorAxisPixel = errorAxis->
orientation() == Qt::Horizontal ? centerPixel.x() : centerPixel.y();
27741 const double centerOrthoAxisPixel = orthoAxis->
orientation() == Qt::Horizontal ? centerPixel.x() : centerPixel.y();
27742 const double centerErrorAxisCoord = errorAxis->
pixelToCoord(centerErrorAxisPixel);
27745 double errorStart, errorEnd;
27746 if (!qIsNaN(it->errorPlus))
27748 errorStart = centerErrorAxisPixel+
symbolGap;
27749 errorEnd = errorAxis->
coordToPixel(centerErrorAxisCoord+it->errorPlus);
27753 backbones.append(QLineF(centerOrthoAxisPixel, errorStart, centerOrthoAxisPixel, errorEnd));
27754 whiskers.append(QLineF(centerOrthoAxisPixel-
mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+
mWhiskerWidth*0.5, errorEnd));
27758 backbones.append(QLineF(errorStart, centerOrthoAxisPixel, errorEnd, centerOrthoAxisPixel));
27759 whiskers.append(QLineF(errorEnd, centerOrthoAxisPixel-
mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+
mWhiskerWidth*0.5));
27763 if (!qIsNaN(it->errorMinus))
27765 errorStart = centerErrorAxisPixel-
symbolGap;
27766 errorEnd = errorAxis->
coordToPixel(centerErrorAxisCoord-it->errorMinus);
27770 backbones.append(QLineF(centerOrthoAxisPixel, errorStart, centerOrthoAxisPixel, errorEnd));
27771 whiskers.append(QLineF(centerOrthoAxisPixel-
mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+
mWhiskerWidth*0.5, errorEnd));
27775 backbones.append(QLineF(errorStart, centerOrthoAxisPixel, errorEnd, centerOrthoAxisPixel));
27776 whiskers.append(QLineF(errorEnd, centerOrthoAxisPixel-
mWhiskerWidth*0.5, errorEnd, centerOrthoAxisPixel+
mWhiskerWidth*0.5));
27803 if (!keyAxis || !valueAxis)
27805 qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
27822 dataRange = dataRange.
bounded(rangeRestriction);
27832 int i = beginIndex;
27833 while (i > 0 && i < n && i > rangeRestriction.
begin())
27840 while (i >= 0 && i < n && i < rangeRestriction.
end())
27865 qDebug() << Q_FUNC_INFO <<
"invalid key or value axis";
27869 QCPErrorBarsDataContainer::const_iterator begin, end;
27873 double minDistSqr = std::numeric_limits<double>::max();
27874 QVector<QLineF> backbones, whiskers;
27875 for (QCPErrorBarsDataContainer::const_iterator it=begin; it!=end; ++it)
27878 for (
int i=0; i<backbones.size(); ++i)
27881 if (currentDistSqr < minDistSqr)
27883 minDistSqr = currentDistSqr;
27888 return qSqrt(minDistSqr);
27900 selectedSegments.clear();
27901 unselectedSegments.clear();
27907 unselectedSegments << QCPDataRange(0,
dataCount());
27928 QPointF centerPixel =
mDataPlottable->interface1D()->dataPixelPosition(index);
27929 const double centerKeyPixel =
mKeyAxis->orientation() == Qt::Horizontal ? centerPixel.x() : centerPixel.y();
27930 if (qIsNaN(centerKeyPixel))
27933 double keyMin, keyMax;
27936 const double centerKey =
mKeyAxis->pixelToCoord(centerKeyPixel);
27939 keyMax = centerKey+(qIsNaN(errorPlus) ? 0 : errorPlus);
27940 keyMin = centerKey-(qIsNaN(errorMinus) ? 0 : errorMinus);
27946 return ((keyMax >
mKeyAxis->range().lower) && (keyMin < mKeyAxis->range().upper));
27958 if (pixelRect.left() > line.x1() && pixelRect.left() > line.x2())
27960 else if (pixelRect.right() < line.x1() && pixelRect.right() < line.x2())
27962 else if (pixelRect.top() > line.y1() && pixelRect.top() > line.y2())
27964 else if (pixelRect.bottom() < line.y1() && pixelRect.bottom() < line.y2())
27995 point1(createPosition(QLatin1String(
"point1"))),
27996 point2(createPosition(QLatin1String(
"point2")))
28001 setPen(QPen(Qt::black));
28045 double clipPad =
mainPen().widthF();
28048 if (!line.isNull())
28067 if (vec.
x() == 0 && vec.
y() == 0)
28069 if (qFuzzyIsNull(vec.
x()))
28074 gamma = base.
x()-bx + (by-base.
y())*vec.
x()/vec.
y();
28075 if (gamma >= 0 && gamma <= rect.width())
28076 result.setLine(bx+gamma, rect.top(), bx+gamma, rect.bottom());
28077 }
else if (qFuzzyIsNull(vec.
y()))
28082 gamma = base.
y()-by + (bx-base.
x())*vec.
y()/vec.
x();
28083 if (gamma >= 0 && gamma <= rect.height())
28084 result.setLine(rect.left(), by+gamma, rect.right(), by+gamma);
28087 QList<QCPVector2D> pointVectors;
28091 gamma = base.
x()-bx + (by-base.
y())*vec.
x()/vec.
y();
28092 if (gamma >= 0 && gamma <= rect.width())
28096 by = rect.bottom();
28097 gamma = base.
x()-bx + (by-base.
y())*vec.
x()/vec.
y();
28098 if (gamma >= 0 && gamma <= rect.width())
28103 gamma = base.
y()-by + (bx-base.
x())*vec.
y()/vec.
x();
28104 if (gamma >= 0 && gamma <= rect.height())
28109 gamma = base.
y()-by + (bx-base.
x())*vec.
y()/vec.
x();
28110 if (gamma >= 0 && gamma <= rect.height())
28114 if (pointVectors.size() == 2)
28116 result.setPoints(pointVectors.at(0).toPointF(), pointVectors.at(1).toPointF());
28117 }
else if (pointVectors.size() > 2)
28120 double distSqrMax = 0;
28122 for (
int i=0; i<pointVectors.size()-1; ++i)
28124 for (
int k=i+1; k<pointVectors.size(); ++k)
28126 double distSqr = (pointVectors.at(i)-pointVectors.at(k)).lengthSquared();
28127 if (distSqr > distSqrMax)
28129 pv1 = pointVectors.at(i);
28130 pv2 = pointVectors.at(k);
28131 distSqrMax = distSqr;
28184 setPen(QPen(Qt::black));
28253 if (qFuzzyIsNull((startVec-endVec).lengthSquared()))
28257 clipPad = qMax(clipPad, (
double)
mainPen().widthF());
28260 if (!line.isNull())
28264 painter->setBrush(Qt::SolidPattern);
28266 mTail.
draw(painter, startVec, startVec-endVec);
28268 mHead.
draw(painter, endVec, endVec-startVec);
28281 bool containsStart = rect.contains(start.
x(), start.
y());
28282 bool containsEnd = rect.contains(end.
x(), end.
y());
28283 if (containsStart && containsEnd)
28291 QList<QCPVector2D> pointVectors;
28293 if (!qFuzzyIsNull(vec.
y()))
28298 mu = (by-base.y())/vec.
y();
28299 if (mu >= 0 && mu <= 1)
28301 gamma = base.x()-bx + mu*vec.
x();
28302 if (gamma >= 0 && gamma <= rect.width())
28307 by = rect.bottom();
28308 mu = (by-base.y())/vec.
y();
28309 if (mu >= 0 && mu <= 1)
28311 gamma = base.x()-bx + mu*vec.
x();
28312 if (gamma >= 0 && gamma <= rect.width())
28316 if (!qFuzzyIsNull(vec.
x()))
28321 mu = (bx-base.x())/vec.
x();
28322 if (mu >= 0 && mu <= 1)
28324 gamma = base.y()-by + mu*vec.
y();
28325 if (gamma >= 0 && gamma <= rect.height())
28331 mu = (bx-base.x())/vec.
x();
28332 if (mu >= 0 && mu <= 1)
28334 gamma = base.y()-by + mu*vec.
y();
28335 if (gamma >= 0 && gamma <= rect.height())
28341 pointVectors.append(start);
28343 pointVectors.append(end);
28346 if (pointVectors.size() == 2)
28348 result.setPoints(pointVectors.at(0).toPointF(), pointVectors.at(1).toPointF());
28349 }
else if (pointVectors.size() > 2)
28352 double distSqrMax = 0;
28354 for (
int i=0; i<pointVectors.size()-1; ++i)
28356 for (
int k=i+1; k<pointVectors.size(); ++k)
28358 double distSqr = (pointVectors.at(i)-pointVectors.at(k)).lengthSquared();
28359 if (distSqr > distSqrMax)
28361 pv1 = pointVectors.at(i);
28362 pv2 = pointVectors.at(k);
28363 distSqrMax = distSqr;
28426 setPen(QPen(Qt::black));
28492 QPainterPath cubicPath(startVec);
28493 cubicPath.cubicTo(startDirVec, endDirVec, endVec);
28495 QPolygonF polygon = cubicPath.toSubpathPolygons().first();
28497 double minDistSqr = std::numeric_limits<double>::max();
28498 for (
int i=1; i<polygon.size(); ++i)
28501 if (distSqr < minDistSqr)
28502 minDistSqr = distSqr;
28504 return qSqrt(minDistSqr);
28514 if ((endVec-startVec).length() > 1e10)
28517 QPainterPath cubicPath(startVec.toPointF());
28518 cubicPath.cubicTo(startDirVec.toPointF(), endDirVec.toPointF(), endVec.toPointF());
28522 QRect cubicRect = cubicPath.controlPointRect().toRect();
28523 if (cubicRect.isEmpty())
28524 cubicRect.adjust(0, 0, 1, 1);
28525 if (clip.intersects(cubicRect))
28528 painter->drawPath(cubicPath);
28529 painter->setBrush(Qt::SolidPattern);
28531 mTail.
draw(painter, startVec, M_PI-cubicPath.angleAtPercent(0)/180.0*M_PI);
28533 mHead.
draw(painter, endVec, -cubicPath.angleAtPercent(1)/180.0*M_PI);
28575 topRight(
createAnchor(QLatin1String(
"topRight"), aiTopRight)),
28577 bottom(
createAnchor(QLatin1String(
"bottom"), aiBottom)),
28578 bottomLeft(
createAnchor(QLatin1String(
"bottomLeft"), aiBottomLeft)),
28584 setPen(QPen(Qt::black));
28644 bool filledRect =
mBrush.style() != Qt::NoBrush &&
mBrush.color().alpha() != 0;
28653 if (p1.toPoint() == p2.toPoint())
28655 QRectF rect = QRectF(p1, p2).normalized();
28656 double clipPad =
mainPen().widthF();
28657 QRectF boundingRect = rect.adjusted(-clipPad, -clipPad, clipPad, clipPad);
28658 if (boundingRect.intersects(
clipRect()))
28662 painter->drawRect(rect);
28672 case aiTop:
return (rect.topLeft()+rect.topRight())*0.5;
28674 case aiRight:
return (rect.topRight()+rect.bottomRight())*0.5;
28675 case aiBottom:
return (rect.bottomLeft()+rect.bottomRight())*0.5;
28677 case aiLeft:
return (rect.topLeft()+rect.bottomLeft())*0.5;
28680 qDebug() << Q_FUNC_INFO <<
"invalid anchorId" << anchorId;
28744 mText(QLatin1String(
"text")),
28745 mPositionAlignment(Qt::AlignCenter),
28746 mTextAlignment(Qt::AlignTop|Qt::AlignHCenter),
28907 QTransform inputTransform;
28908 inputTransform.translate(positionPixels.x(), positionPixels.y());
28910 inputTransform.translate(-positionPixels.x(), -positionPixels.y());
28911 QPointF rotatedPos = inputTransform.map(pos);
28912 QFontMetrics fontMetrics(
mFont);
28913 QRect textRect = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip|
mTextAlignment,
mText);
28916 textBoxRect.moveTopLeft(textPos.toPoint());
28925 QTransform transform = painter->transform();
28926 transform.translate(pos.x(), pos.y());
28930 QRect textRect = painter->fontMetrics().boundingRect(0, 0, 0, 0, Qt::TextDontClip|
mTextAlignment,
mText);
28933 textRect.moveTopLeft(textPos.toPoint()+QPoint(
mPadding.left(),
mPadding.top()));
28934 textBoxRect.moveTopLeft(textPos.toPoint());
28935 double clipPad =
mainPen().widthF();
28936 QRect boundingRect = textBoxRect.adjusted(-clipPad, -clipPad, clipPad, clipPad);
28937 if (transform.mapRect(boundingRect).intersects(painter->transform().mapRect(
clipRect())))
28939 painter->setTransform(transform);
28945 painter->drawRect(textBoxRect);
28947 painter->setBrush(Qt::NoBrush);
28958 QTransform transform;
28959 transform.translate(pos.x(), pos.y());
28962 QFontMetrics fontMetrics(
mainFont());
28963 QRect textRect = fontMetrics.boundingRect(0, 0, 0, 0, Qt::TextDontClip|
mTextAlignment,
mText);
28966 textBoxRect.moveTopLeft(textPos.toPoint());
28967 QPolygonF rectPoly = transform.map(QPolygonF(textBoxRect));
28972 case aiTop:
return (rectPoly.at(0)+rectPoly.at(1))*0.5;
28974 case aiRight:
return (rectPoly.at(1)+rectPoly.at(2))*0.5;
28976 case aiBottom:
return (rectPoly.at(2)+rectPoly.at(3))*0.5;
28978 case aiLeft:
return (rectPoly.at(3)+rectPoly.at(0))*0.5;
28981 qDebug() << Q_FUNC_INFO <<
"invalid anchorId" << anchorId;
28997 if (positionAlignment == 0 || positionAlignment == (Qt::AlignLeft|Qt::AlignTop))
29000 QPointF result = pos;
29001 if (positionAlignment.testFlag(Qt::AlignHCenter))
29002 result.rx() -= rect.width()/2.0;
29003 else if (positionAlignment.testFlag(Qt::AlignRight))
29004 result.rx() -= rect.width();
29005 if (positionAlignment.testFlag(Qt::AlignVCenter))
29006 result.ry() -= rect.height()/2.0;
29007 else if (positionAlignment.testFlag(Qt::AlignBottom))
29008 result.ry() -= rect.height();
29079 topLeftRim(
createAnchor(QLatin1String(
"topLeftRim"), aiTopLeftRim)),
29081 topRightRim(
createAnchor(QLatin1String(
"topRightRim"), aiTopRightRim)),
29083 bottomRightRim(
createAnchor(QLatin1String(
"bottomRightRim"), aiBottomRightRim)),
29085 bottomLeftRim(
createAnchor(QLatin1String(
"bottomLeftRim"), aiBottomLeftRim)),
29087 center(
createAnchor(QLatin1String(
"center"), aiCenter))
29092 setPen(QPen(Qt::black));
29153 QPointF
center((p1+p2)/2.0);
29154 double a = qAbs(p1.x()-p2.x())/2.0;
29155 double b = qAbs(p1.y()-p2.y())/2.0;
29156 double x = pos.x()-center.x();
29157 double y = pos.y()-center.y();
29160 double c = 1.0/qSqrt(x*x/(a*a)+y*y/(b*b));
29161 double result = qAbs(c-1)*qSqrt(x*x+y*y);
29165 if (x*x/(a*a) + y*y/(b*b) <= 1)
29176 if (p1.toPoint() == p2.toPoint())
29178 QRectF ellipseRect = QRectF(p1, p2).normalized();
29180 if (ellipseRect.intersects(clip))
29184 #ifdef __EXCEPTIONS 29188 painter->drawEllipse(ellipseRect);
29189 #ifdef __EXCEPTIONS 29192 qDebug() << Q_FUNC_INFO <<
"Item too large for memory, setting invisible";
29205 case aiTopLeftRim:
return rect.center()+(rect.topLeft()-rect.center())*1/qSqrt(2);
29206 case aiTop:
return (rect.topLeft()+rect.topRight())*0.5;
29207 case aiTopRightRim:
return rect.center()+(rect.topRight()-rect.center())*1/qSqrt(2);
29208 case aiRight:
return (rect.topRight()+rect.bottomRight())*0.5;
29209 case aiBottomRightRim:
return rect.center()+(rect.bottomRight()-rect.center())*1/qSqrt(2);
29210 case aiBottom:
return (rect.bottomLeft()+rect.bottomRight())*0.5;
29211 case aiBottomLeftRim:
return rect.center()+(rect.bottomLeft()-rect.center())*1/qSqrt(2);
29212 case aiLeft:
return (rect.topLeft()+rect.bottomLeft())*0.5;
29213 case aiCenter:
return (rect.topLeft()+rect.bottomRight())*0.5;
29216 qDebug() << Q_FUNC_INFO <<
"invalid anchorId" << anchorId;
29274 topRight(
createAnchor(QLatin1String(
"topRight"), aiTopRight)),
29277 bottomLeft(
createAnchor(QLatin1String(
"bottomLeft"), aiBottomLeft)),
29280 mScaledPixmapInvalidated(true),
29281 mAspectRatioMode(Qt::KeepAspectRatio),
29282 mTransformationMode(Qt::SmoothTransformation)
29303 qDebug() << Q_FUNC_INFO <<
"pixmap is null";
29351 bool flipHorz =
false;
29352 bool flipVert =
false;
29354 double clipPad =
mainPen().style() == Qt::NoPen ? 0 :
mainPen().widthF();
29355 QRect boundingRect = rect.adjusted(-clipPad, -clipPad, clipPad, clipPad);
29356 if (boundingRect.intersects(
clipRect()))
29361 if (pen.style() != Qt::NoPen)
29364 painter->setBrush(Qt::NoBrush);
29365 painter->drawRect(rect);
29379 rect.adjust(rect.width(), 0, -rect.width(), 0);
29381 rect.adjust(0, rect.height(), 0, -rect.height());
29385 case aiTop:
return (rect.topLeft()+rect.topRight())*0.5;
29387 case aiRight:
return (rect.topRight()+rect.bottomRight())*0.5;
29388 case aiBottom:
return (rect.bottomLeft()+rect.bottomRight())*0.5;
29390 case aiLeft:
return (rect.topLeft()+rect.bottomLeft())*0.5;;
29393 qDebug() << Q_FUNC_INFO <<
"invalid anchorId" << anchorId;
29417 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 29418 double devicePixelRatio =
mPixmap.devicePixelRatio();
29420 double devicePixelRatio = 1.0;
29422 if (finalRect.isNull())
29427 if (flipHorz || flipVert)
29429 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 29455 bool flipHorz =
false;
29456 bool flipVert =
false;
29460 return QRect(p1, QSize(0, 0));
29463 QSize newSize = QSize(p2.x()-p1.x(), p2.y()-p1.y());
29465 if (newSize.width() < 0)
29468 newSize.rwidth() *= -1;
29469 topLeft.setX(p2.x());
29471 if (newSize.height() < 0)
29474 newSize.rheight() *= -1;
29475 topLeft.setY(p2.y());
29477 QSize scaledSize =
mPixmap.size();
29478 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 29479 scaledSize /=
mPixmap.devicePixelRatio();
29484 result = QRect(topLeft, scaledSize);
29487 #ifdef QCP_DEVICEPIXELRATIO_SUPPORTED 29490 result = QRect(p1,
mPixmap.size());
29494 *flippedHorz = flipHorz;
29496 *flippedVert = flipVert;
29559 mStyle(tsCrosshair),
29562 mInterpolating(false)
29568 setPen(QPen(Qt::black));
29657 qDebug() << Q_FUNC_INFO <<
"graph isn't in same QCustomPlot instance as this item";
29702 double w =
mSize/2.0;
29709 if (
clipRect().intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect()))
29710 return qSqrt(qMin(
QCPVector2D(pos).distanceSquaredToLine(center+QPointF(-w, 0), center+QPointF(w, 0)),
29711 QCPVector2D(pos).distanceSquaredToLine(center+QPointF(0, -w), center+QPointF(0, w))));
29721 if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect()))
29725 double circleLine = w;
29726 double result = qAbs(centerDist-circleLine);
29730 if (centerDist <= circleLine)
29739 if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect()))
29741 QRectF rect = QRectF(center-QPointF(w, w), center+QPointF(w, w));
29742 bool filledRect =
mBrush.style() != Qt::NoBrush &&
mBrush.color().alpha() != 0;
29761 double w =
mSize/2.0;
29768 if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect()))
29770 painter->
drawLine(QLineF(center+QPointF(-w, 0), center+QPointF(w, 0)));
29771 painter->
drawLine(QLineF(center+QPointF(0, -w), center+QPointF(0, w)));
29777 if (center.y() > clip.top() && center.y() < clip.bottom())
29778 painter->
drawLine(QLineF(clip.left(), center.y(), clip.right(), center.y()));
29779 if (center.x() > clip.left() && center.x() < clip.right())
29780 painter->
drawLine(QLineF(center.x(), clip.top(), center.x(), clip.bottom()));
29785 if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect()))
29786 painter->drawEllipse(center, w, w);
29791 if (clip.intersects(QRectF(center-QPointF(w, w), center+QPointF(w, w)).toRect()))
29792 painter->drawRect(QRectF(center-QPointF(w, w), center+QPointF(w, w)));
29820 if (mGraphKey <= first->key)
29835 if (!qFuzzyCompare((
double)it->key, (
double)prevIt->key))
29836 slope = (it->value-prevIt->value)/(it->key-prevIt->key);
29841 if (
mGraphKey < (prevIt->key+it->key)*0.5)
29854 qDebug() << Q_FUNC_INFO <<
"graph has no data";
29856 qDebug() << Q_FUNC_INFO <<
"graph not contained in QCustomPlot instance (anymore)";
29919 center(
createAnchor(QLatin1String(
"center"), aiCenter)),
29926 setPen(QPen(Qt::black));
29991 if (leftVec.toPoint() == rightVec.toPoint())
29996 QCPVector2D centerVec = (rightVec+leftVec)*0.5-lengthVec;
30006 return qSqrt(qMin(qMin(a, b), c));
30011 double a = p.
distanceSquaredToLine(centerVec-widthVec*0.75+lengthVec*0.15, centerVec+lengthVec*0.3);
30012 double b = p.
distanceSquaredToLine(centerVec-widthVec+lengthVec*0.7, centerVec-widthVec*0.75+lengthVec*0.15);
30013 double c = p.
distanceSquaredToLine(centerVec+widthVec*0.75+lengthVec*0.15, centerVec+lengthVec*0.3);
30014 double d = p.
distanceSquaredToLine(centerVec+widthVec+lengthVec*0.7, centerVec+widthVec*0.75+lengthVec*0.15);
30015 return qSqrt(qMin(qMin(a, b), qMin(c, d)));
30026 if (leftVec.toPoint() == rightVec.toPoint())
30031 QCPVector2D centerVec = (rightVec+leftVec)*0.5-lengthVec;
30033 QPolygon boundingPoly;
30034 boundingPoly << leftVec.
toPoint() << rightVec.toPoint()
30035 << (rightVec-lengthVec).toPoint() << (leftVec-lengthVec).toPoint();
30037 if (clip.intersects(boundingPoly.boundingRect()))
30044 painter->
drawLine((centerVec+widthVec).toPointF(), (centerVec-widthVec).toPointF());
30045 painter->
drawLine((centerVec+widthVec).toPointF(), (centerVec+widthVec+lengthVec).toPointF());
30046 painter->
drawLine((centerVec-widthVec).toPointF(), (centerVec-widthVec+lengthVec).toPointF());
30051 painter->setBrush(Qt::NoBrush);
30053 path.moveTo((centerVec+widthVec+lengthVec).toPointF());
30054 path.cubicTo((centerVec+widthVec).toPointF(), (centerVec+widthVec).toPointF(), centerVec.
toPointF());
30055 path.cubicTo((centerVec-widthVec).toPointF(), (centerVec-widthVec).toPointF(), (centerVec-widthVec+lengthVec).toPointF());
30056 painter->drawPath(path);
30061 painter->setBrush(Qt::NoBrush);
30063 path.moveTo((centerVec+widthVec+lengthVec).toPointF());
30064 path.cubicTo((centerVec+widthVec-lengthVec*0.8).toPointF(), (centerVec+0.4*widthVec+lengthVec).toPointF(), centerVec.
toPointF());
30065 path.cubicTo((centerVec-0.4*widthVec+lengthVec).toPointF(), (centerVec-widthVec-lengthVec*0.8).toPointF(), (centerVec-widthVec+lengthVec).toPointF());
30066 painter->drawPath(path);
30071 painter->
setPen(Qt::NoPen);
30072 painter->setBrush(QBrush(
mainPen().color()));
30074 path.moveTo((centerVec+widthVec+lengthVec).toPointF());
30076 path.cubicTo((centerVec+widthVec-lengthVec*0.8).toPointF(), (centerVec+0.4*widthVec+0.8*lengthVec).toPointF(), centerVec.
toPointF());
30077 path.cubicTo((centerVec-0.4*widthVec+0.8*lengthVec).toPointF(), (centerVec-widthVec-lengthVec*0.8).toPointF(), (centerVec-widthVec+lengthVec).toPointF());
30079 path.cubicTo((centerVec-widthVec-lengthVec*0.5).toPointF(), (centerVec-0.2*widthVec+1.2*lengthVec).toPointF(), (centerVec+lengthVec*0.2).toPointF());
30080 path.cubicTo((centerVec+0.2*widthVec+1.2*lengthVec).toPointF(), (centerVec+widthVec-lengthVec*0.5).toPointF(), (centerVec+widthVec+lengthVec).toPointF());
30082 painter->drawPath(path);
30094 if (leftVec.toPoint() == rightVec.toPoint())
30099 QCPVector2D centerVec = (rightVec+leftVec)*0.5-lengthVec;
30106 qDebug() << Q_FUNC_INFO <<
"invalid anchorId" << anchorId;
double devicePixelRatio() const
double pointDistance(const QPointF &pixelPoint, QCPGraphDataContainer::const_iterator &closestData) const
QList< QList< QCPLayoutElement * > > mElements
QSharedPointer< QCPCurveDataContainer > data() const
QCP::AntialiasedElements mNotAADragBackup
double cleanMantissa(double input) const
void setType(PositionType type)
QCPLayoutElement(QCustomPlot *parentPlot=0)
QCPColorScaleAxisRectPrivate(QCPColorScale *parentColorScale)
void itemClick(QCPAbstractItem *item, QMouseEvent *event)
void drawSubGridLines(QCPPainter *painter) const
Q_SLOT void setSelection(QCPDataSelection selection)
QList< QSharedPointer< QCPAbstractPaintBuffer > > mPaintBuffers
void addElement(QCPLayoutElement *element, Qt::Alignment alignment)
QCPItemPosition * position(const QString &name) const
void insertRow(int newIndex)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
QVector< QPointF > dataToStepLeftLines(const QVector< QCPGraphData > &data) const
SizeConstraintRect sizeConstraintRect() const
A margin group allows synchronization of margin sides if working with multiple layout elements...
One individual data point can be selected at a time.
QList< QCPGraph * > mGraphs
QCPGraph * addGraph(QCPAxis *keyAxis=0, QCPAxis *valueAxis=0)
virtual ~QCPAxisPainterPrivate()
Holds the data of one single error bar for QCPErrorBars.
QCPStatisticalBox(QCPAxis *keyAxis, QCPAxis *valueAxis)
void setSubTickLengthIn(int inside)
void setMargins(const QMargins &margins)
0x04 Turns pen widths 0 to 1, i.e. disables cosmetic pens. (A cosmetic pen is always drawn with width...
void setBracketBrush(const QBrush &brush)
QCPDataRange intersection(const QCPDataRange &other) const
bool stopsUseAlpha() const
virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
QList< QCPLayoutElement * > elements(QCP::MarginSide side) const
void setWhiskerBarPen(const QPen &pen)
double bufferDevicePixelRatio() const
bool savePng(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch)
void setNotAntialiasedElement(QCP::AntialiasedElement notAntialiasedElement, bool enabled=true)
Qt::Orientations mRangeDrag
A plus shaped crosshair which spans the complete axis rect.
virtual void updateLayout()
static const double maxRange
void setPeriodic(bool enabled)
void setLevelCount(int n)
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
QRgb color(double position, const QCPRange &range, bool logarithmic=false)
void setBracketWidth(int width)
void setTimeFormat(const QString &format)
void setInsetPlacement(int index, InsetPlacement placement)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Q_SLOT void axisSelectableChanged(QCPAxis::SelectableParts selectableParts)
bool isInvalidData(double value)
virtual QVector< double > createTickVector(double tickStep, const QCPRange &range) Q_DECL_OVERRIDE
virtual void updateMapImage()
QSharedPointer< QCPDataContainer< QCPGraphData > > mDataContainer
virtual int elementCount() const Q_DECL_OVERRIDE
void setTickOrigin(double origin)
void setScatterStyle(const QCPScatterStyle &scatterStyle, QCPScatterStyle::ScatterProperties usedProperties=QCPScatterStyle::spPen)
QCPColorGradient gradient() const
QCPAxis * rangeZoomAxis(Qt::Orientation orientation)
void setLowerEnding(const QCPLineEnding &ending)
Open-High-Low-Close bar representation.
An ellipse is drawn. The size of the ellipse is given by the bracket width/height properties...
bool clipToAxisRect() const
bool registerGraph(QCPGraph *graph)
QCPAxisRect * axisRectAt(const QPointF &pos) const
void setBackgroundScaledMode(Qt::AspectRatioMode mode)
QCPItemPosition *const end
Q_SLOT void replot(QCustomPlot::RefreshPriority refreshPriority=QCustomPlot::rpRefreshHint)
void plottableDoubleClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event)
void updateAxesOffset(QCPAxis::AxisType type)
QCPVector2D & operator+=(const QCPVector2D &vector)
QCPColorMapData * mMapData
QCPPlottableLegendItem(QCPLegend *parent, QCPAbstractPlottable *plottable)
int plottableCount() const
QCPLayout * mParentLayout
virtual int calculateAutoMargin(QCP::MarginSide side) Q_DECL_OVERRIDE
double cell(int keyIndex, int valueIndex)
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE
void dataRangeChanged(const QCPRange &newRange)
Hours (%h in setTimeFormat)
void setMinimumMargins(const QMargins &margins)
The base class tick generator used by QCPAxis to create tick positions and tick labels.
virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE
QCPAxis(QCPAxisRect *parent, AxisType type)
void setScaleRatio(const QCPAxis *otherAxis, double ratio=1.0)
virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE
PainterModes modes() const
QCPRange dataRange() const
void setBrush(const QBrush &brush)
void applyPen(QCPPainter *painter) const
Fractions are written using sub- and superscript UTF-8 digits and the fraction symbol.
virtual void reallocateBuffer()=0
void setAntialiasedElement(QCP::AntialiasedElement antialiasedElement, bool enabled=true)
void setTickOrigin(double origin)
void setKeySize(int keySize)
The abstract base class for paint buffers, which define the rendering backend.
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
virtual QCPLayoutElement * elementAt(int index) const Q_DECL_OVERRIDE
void remove(QCPBars *bars)
QCP::AntialiasedElements antialiasedElements() const
QCPDataSelection selection() const
void setMaximumSize(const QSize &size)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Color channels hue, saturation and value are linearly interpolated (The hue is interpolated over the ...
void setDevicePixelRatio(double ratio)
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Holds the data of one single data point for QCPCurve.
void mouseMove(QMouseEvent *event)
QCPRange keyRange() const
No line is drawn between data points (e.g. only scatters)
QCustomPlot(QWidget *parent=0)
QList< QCPDataRange > dataRanges() const
void setParentLayerable(QCPLayerable *parentLayerable)
QCPItemBracket(QCustomPlot *parentPlot)
QCPLineEnding tail() const
void rescaleKeyAxis(bool onlyEnlarge=false) const
void addData(const QVector< double > &keys, const QVector< double > &values, bool alreadySorted=false)
bool mNumberBeautifulPowers
QCPItemAnchor *const center
virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE
A legend item representing a plottable with an icon and the plottable name.
QHash< QCP::MarginSide, QCPMarginGroup * > mMarginGroups
Bar spacing is given by a fraction of the axis rect size.
bool antialiasing() const
virtual double dataMainValue(int index) const =0
void setType(QCPAxis::AxisType type)
void setIconTextPadding(int padding)
each data point is represented by a line parallel to the value axis, which reaches from the data poin...
QCPItemPosition *const start
void selectionChanged(bool selected)
int numberPrecision() const
virtual QList< QCPLayoutElement * > elements(bool recursive) const
void expandTo(int newRowCount, int newColumnCount)
SelectableParts selectedParts() const
virtual void reallocateBuffer() Q_DECL_OVERRIDE
virtual void drawFill(QCPPainter *painter, QVector< QPointF > *lines) const
QByteArray mLabelParameterHash
0x01 Mode for vectorized painting (e.g. PDF export). For example, this prevents some antialiasing fix...
void applyBrush(QCPPainter *painter) const
void setMedianPen(const QPen &pen)
QCPRange bounded(double lowerBound, double upperBound) const
QList< QCPAbstractPlottable * > selectedPlottables() const
void selectionChanged(bool selected)
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
Q_SLOT bool setLayer(QCPLayer *layer)
QList< QCPGraph * > graphs() const
QCPAbstractPlottable * plottable()
bool contains(double value) const
bool registerPlottable(QCPAbstractPlottable *plottable)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
The axis backbone and tick marks.
void setTickStepStrategy(TickStepStrategy strategy)
Fractions are displayed as regular decimal floating point numbers, e.g. "0.25" or "0...
double realLength() const
QCPLineEnding lowerEnding
static double dateTimeToKey(const QDateTime dateTime)
The errors are for the key dimension (bars appear parallel to the key axis)
EndingStyle style() const
Bar spacing is in key coordinates and thus scales with the key axis range.
QCPItemAnchor * anchor(const QString &name) const
void drawGridLines(QCPPainter *painter) const
void setSpacingType(SpacingType spacingType)
void setSelectedTickLabelFont(const QFont &font)
void setOffset(int offset)
QColor mSelectedTickLabelColor
virtual void wheelEvent(QWheelEvent *event)
void setBasePen(const QPen &pen)
bool hasPlottable(QCPAbstractPlottable *plottable) const
virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE
void addData(const QVector< double > &t, const QVector< double > &keys, const QVector< double > &values, bool alreadySorted=false)
void setVisible(bool visible)
The tracer is not visible.
Controls how a plottable's data selection is drawn.
void simplifyFraction(int &numerator, int &denominator) const
void setSelectedBorderPen(const QPen &pen)
void zoom(const QRectF &pixelRect)
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
void setErrorType(ErrorType type)
virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE
void setPixmap(const QPixmap &pixmap)
QColor getTickLabelColor() const
virtual void updateLayout() Q_DECL_OVERRIDE
QCPItemPosition *const topLeft
SelectableParts mSelectedParts
QList< QCPLayerable * > layerableListAt(const QPointF &pos, bool onlySelectable, QList< QVariant > *selectionDetails=0) const
custom painter operations are performed per scatter (As QPainterPath, see setCustomPath) ...
virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE
The abstract base class for all entries in a QCPLegend.
0x08 The shape property, see setShape
void getVisibleDataBounds(QCPErrorBarsDataContainer::const_iterator &begin, QCPErrorBarsDataContainer::const_iterator &end, const QCPDataRange &rangeRestriction) const
bool hasItemWithPlottable(const QCPAbstractPlottable *plottable) const
const QPolygonF getChannelFillPolygon(const QVector< QPointF > *lineData, QCPDataRange thisSegment, const QVector< QPointF > *otherData, QCPDataRange otherSegment) const
QFont mSelectedTickLabelFont
void setHead(const QCPLineEnding &head)
double ohlcSelectTest(const QPointF &pos, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, QCPFinancialDataContainer::const_iterator &closestDataPoint) const
bool remove(QCPLayoutElement *element)
{ssPeace.png} a circle, with one vertical and two downward diagonal lines
virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Queues the entire replot for the next event loop iteration. This way multiple redundant replots can b...
Tick labels (numbers) of this axis (as a whole, not individually)
bool mAntialiasedZeroLine
void setStyle(BracketStyle style)
virtual void draw(QCPPainter *painter)
void setSubTickCount(int subTicks)
void itemDoubleClick(QCPAbstractItem *item, QMouseEvent *event)
QString fractionToString(int numerator, int denominator) const
An integer multiple of the specified tick step is allowed. The used factor follows the base class pro...
QColor getTextColor() const
void getVisibleDataBounds(QCPBarsDataContainer::const_iterator &begin, QCPBarsDataContainer::const_iterator &end) const
QColor mSelectedTextColor
double dot(const QCPVector2D &vec) const
void addChild(QCPLayerable *layerable, bool prepend)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
void setPenPositive(const QPen &pen)
static AxisType marginSideToAxisType(QCP::MarginSide side)
0x0001 Axis base line and tick marks
QCPItemAnchor * createAnchor(const QString &name, int anchorId)
Q_SLOT void setDataRange(const QCPRange &dataRange)
void setScatterSkip(int skip)
void setName(const QString &name)
QPainterPath customPath() const
void setRowStretchFactors(const QList< double > &factors)
void setRangeReversed(bool reversed)
QPointF getOptimizedPoint(int prevRegion, double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const
QCP::SelectionType selectable() const
void setStackingGap(double pixels)
void setSelectedBasePen(const QPen &pen)
virtual QCPRange dataValueRange(int index) const Q_DECL_OVERRIDE
double getTangentAngle(const QCPPlottableInterface1D *interface1d, int dataIndex, int direction) const
Responsible for drawing the grid of a QCPAxis.
Qt::Alignment positionAlignment() const
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
0x001 Axis ranges are draggable (see QCPAxisRect::setRangeDrag, QCPAxisRect::setRangeDragAxes) ...
QCPItemAnchor * parentAnchor() const
void setTangentToData(bool enabled)
virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE
QVector< QString > tickLabels
void getTraverseCornerPoints(int prevRegion, int currentRegion, double keyMin, double valueMax, double keyMax, double valueMin, QVector< QPointF > &beforeTraverse, QVector< QPointF > &afterTraverse) const
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE
QSize maximumSize() const
void setWhiskerWidth(double width)
void setPen(const QPen &pen)
void changed(const QRect &rect, QMouseEvent *event)
void setTextAlignment(Qt::Alignment alignment)
void gradientChanged(const QCPColorGradient &newGradient)
const QCPRange range() const
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
void dataRangeChanged(const QCPRange &newRange)
width is in key coordinates and thus scales with the key axis range
QCPColorGradient mGradient
void setTicker(QSharedPointer< QCPAxisTicker > ticker)
QList< QCPGraph * > graphs() const
Defines an abstract interface for one-dimensional plottables.
void setSelectedSubTickPen(const QPen &pen)
void legendDoubleClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
int dataPointCount() const
QSharedPointer< QCPStatisticalBoxDataContainer > data() const
The selection rect is disabled, and all mouse events are forwarded to the underlying objects...
QCPColorMapData * data() const
bool noAntialiasingOnDrag() const
QRect axisSelectionBox() const
Provides rect/rubber-band data selection and range zoom interaction.
void setCustomPath(const QPainterPath &customPath)
void getCurveLines(QVector< QPointF > *lines, const QCPDataRange &dataRange, double penWidth) const
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Fractions are written as rationals using ASCII characters only, e.g. "1/4" or "1/8".
double rectDistance(const QRectF &rect, const QPointF &pos, bool filledRect) const
QList< QCPItemPosition * > mPositions
QList< QCPDataRange > mDataRanges
virtual void drawBracket(QCPPainter *painter, int direction) const
void setShape(ScatterShape shape)
QCP::PlottingHints plottingHints() const
QCustomPlot * mParentPlot
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
void setBackgroundScaled(bool scaled)
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
Colors suitable for thermal imaging, ranging from dark blue over purple to orange, yellow and white.
void drawOhlcPlot(QCPPainter *painter, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, bool isSelected)
void setTickLabels(bool show)
An anchor of an item to which positions can be attached to.
A square bracket is drawn.
bool addToLegend(QCPLegend *legend)
ScaleStrategy mScaleStrategy
void setSelectedPen(const QPen &pen)
Qt::Orientations mRangeZoom
void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
void enforceType(QCP::SelectionType type)
void setBrush(const QBrush &brush)
void setData(QSharedPointer< QCPErrorBarsDataContainer > data)
void getVisibleDataBounds(QCPGraphDataContainer::const_iterator &begin, QCPGraphDataContainer::const_iterator &end, const QCPDataRange &rangeRestriction) const
QCPScatterStyle mScatterStyle
virtual QList< QCPLayoutElement * > elements(bool recursive) const Q_DECL_OVERRIDE
void axisDoubleClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
QCPAxis * keyAxis() const
Phase in which the margins are calculated and set.
Q_SLOT void setSelectableParts(const QCPAxis::SelectableParts &selectableParts)
void setSelectedIconBorderPen(const QPen &pen)
Static positioning in pixels, starting from the top left corner of the viewport/widget.
void setAntialiasedScatters(bool enabled)
void setRangeZoom(Qt::Orientations orientations)
virtual QRect clipRect() const Q_DECL_OVERRIDE
QCPItemRect(QCustomPlot *parentPlot)
QCPItemAnchor * mParentAnchorX
void indexToRowCol(int index, int &row, int &column) const
QCache< QString, CachedLabel > mLabelCache
void mouseRelease(QMouseEvent *event)
A brace with angled edges.
void setSelectedPen(const QPen &pen)
QCPItemPosition *const right
void setWhiskerPen(const QPen &pen)
void setAdaptiveSampling(bool enabled)
int findIndexAboveY(const QVector< QPointF > *data, double y) const
void getScatters(QVector< QPointF > *scatters, const QCPDataRange &dataRange, double scatterWidth) const
QVector< double > subTickPositions
void rangeChanged(const QCPRange &newRange)
void setSelectionDecorator(QCPSelectionDecorator *decorator)
virtual QList< QCPLayoutElement * > elements(bool recursive) const Q_DECL_OVERRIDE
A plus shaped crosshair with limited size.
void rescaleDataRange(bool onlyVisibleMaps)
void mouseDoubleClick(QMouseEvent *event)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
void setupFullAxesBox(bool connectRanges=false)
void setText(const QString &text)
QCPItemLine(QCustomPlot *parentPlot)
void setRangeZoomAxes(QCPAxis *horizontal, QCPAxis *vertical)
Q_SLOT void setSelectableParts(const SelectableParts &selectableParts)
QCPAxis * addAxis(QCPAxis::AxisType type, QCPAxis *axis=0)
double tickLabelRotation() const
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
QCPLineEnding head() const
void setFromOther(const QCPScatterStyle &other, ScatterProperties properties)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
static bool validRange(double lower, double upper)
Base class for all drawable objects.
QPixmap mBackgroundPixmap
void setInterpolating(bool enabled)
void setValueAxis(QCPAxis *axis)
bool segmentsIntersect(double aLower, double aUpper, double bLower, double bUpper, int &bPrecedence) const
QSharedPointer< QCPAxisTicker > ticker() const
double distanceSquaredToLine(const QCPVector2D &start, const QCPVector2D &end) const
bool mGradientImageInvalidated
void setBackground(const QPixmap &pm)
double getPixelSpacing(const QCPBars *bars, double keyCoord)
void setPadding(int padding)
bool removeFromLegend(QCPLegend *legend) const
virtual Q_SLOT void processRectSelection(QRect rect, QMouseEvent *event)
A plottable representing a bar chart in a plot.
const QCP::Interactions interactions() const
virtual QCPPlottableInterface1D * interface1D()
virtual int findEnd(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE
bool removeGraph(QCPGraph *graph)
QVector< double > mTickVector
void setRange(const QCPRange &keyRange, const QCPRange &valueRange)
void setBrush(const QBrush &brush)
0x080 All other objects are selectable (e.g. your own derived layerables, other layout elements...
QList< QCPAbstractPlottable * > plottables() const
virtual void layoutChanged() Q_DECL_OVERRIDE
void setCoords(double key, double value)
void addChild(QCP::MarginSide side, QCPLayoutElement *element)
void colorize(const double *data, const QCPRange &range, QRgb *scanLine, int n, int dataIndexFactor=1, bool logarithmic=false)
0x0080 Scatter symbols of plottables (excluding scatter symbols of type ssPixmap) ...
friend class QCPItemAnchor
Q_SLOT void setSelectable(bool selectable)
void setWidth(double width)
void loadPreset(GradientPreset preset)
void moveAbove(QCPBars *bars)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void setSize(int keySize, int valueSize)
void moveBelow(QCPBars *bars)
QSharedPointer< QCPFinancialDataContainer > data() const
void setScatterStyle(const QCPScatterStyle &style)
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
void setInteraction(const QCP::Interaction &interaction, bool enabled=true)
virtual void simplify() Q_DECL_OVERRIDE
void setRangeUpper(double upper)
virtual ~QCPMarginGroup()
void setModes(PainterModes modes)
virtual QPointF pixelPosition() const
void setData(QSharedPointer< QCPBarsDataContainer > data)
QCPItemTracer(QCustomPlot *parentPlot)
virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos)
void recalculateDataBounds()
double getPixelWidth(double key, double keyPixel) const
bool contains(const QCPDataSelection &other) const
QColor mSelectedTextColor
virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos)
virtual QRect clipRect() const
virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE
bool mScaledPixmapInvalidated
virtual QCP::Interaction selectionCategory() const
void trimTicks(const QCPRange &range, QVector< double > &ticks, bool keepOneOutlier) const
void layerChanged(QCPLayer *newLayer)
virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE
bool addElement(int row, int column, QCPLayoutElement *element)
void setStyle(EndingStyle style)
QPointer< QCPBars > mBarBelow
void setValueSize(int valueSize)
QPointF getFillBasePoint(QPointF matchingDataPoint) const
void addData(const QVector< double > &keys, const QVector< double > &minimum, const QVector< double > &lowerQuartile, const QVector< double > &median, const QVector< double > &upperQuartile, const QVector< double > &maximum, bool alreadySorted=false)
virtual ~QCPLayoutElement()
QList< QCPRange > mDragStartHorzRange
QList< QCPLayerable * > children() const
void setTickLabelRotation(double degrees)
QCPScatterStyle mScatterStyle
void setTypeX(PositionType type)
0x02 Mode for all sorts of exports (e.g. PNG, PDF,...). For example, this prevents using cached pixma...
QCPBars(QCPAxis *keyAxis, QCPAxis *valueAxis)
A layout that arranges child elements in a grid.
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
QCPVector2D & operator-=(const QCPVector2D &vector)
void setPen(const QPen &pen)
int pixelOrientation() const
void setFont(const QFont &font)
void setColor(const QColor &color)
bool registerItem(QCPAbstractItem *item)
void selectionChangedByUser()
virtual bool take(QCPLayoutElement *element) Q_DECL_OVERRIDE
Minimum/Maximum size constraints apply to inner rect.
0x08 Axis is horizontal and on the bottom side of the axis rect
QPointer< QCPAbstractPlottable > mDataPlottable
double mBufferDevicePixelRatio
QPointer< QCPBars > mBarAbove
QCPScatterStyle mOutlierStyle
void setUpperEnding(const QCPLineEnding &ending)
void setPixmap(const QPixmap &pixmap)
void setWidth(double width)
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
Multiple contiguous data points (a data range) can be selected.
QCPItemText(QCustomPlot *parentPlot)
virtual bool registerWithPlottable(QCPAbstractPlottable *plottable)
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
void setUsedScatterProperties(const QCPScatterStyle::ScatterProperties &properties)
QList< QCPLayer * > mLayers
Seconds (%s in setTimeFormat)
void setRangeDrag(Qt::Orientations orientations)
void setTangentAverage(int pointCount)
QCP::AntialiasedElements mNotAntialiasedElements
virtual void generate(const QCPRange &range, const QLocale &locale, QChar formatChar, int precision, QVector< double > &ticks, QVector< double > *subTicks, QVector< QString > *tickLabels)
QCPItemAnchor *const bottom
void setSize(const QSize &size)
QCPDataRange expanded(const QCPDataRange &other) const
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
0x0040 Main lines of items
void removeChild(QCPLayerable *layerable)
QCPAxisRect * axisRect() const
QImage mUndersampledMapImage
Represents two doubles as a mathematical 2D vector.
QCPVector2D perpendicular() const
Holds the data of one single data point for QCPGraph.
QCPDataSelection & operator-=(const QCPDataSelection &other)
no scatter symbols are drawn (e.g. in QCPGraph, data only represented with lines) ...
bool begin(QPaintDevice *device)
void setSelectedTextColor(const QColor &color)
virtual void drawTickLabel(QCPPainter *painter, double x, double y, const TickLabelData &labelData) const
virtual void placeTickLabel(QCPPainter *painter, double position, int distanceToAxis, const QString &text, QSize *tickLabelsSize)
void updateScaledPixmap(QRect finalRect=QRect(), bool flipHorz=false, bool flipVert=false)
double getMantissa(double input, double *magnitude=0) const
QCPLineEnding upperEnding() const
The abstract base class for all data representing objects in a plot.
QCP::MarginSides mAutoMargins
FractionStyle mFractionStyle
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void selectionChanged(bool selected)
void setColorScale(QCPColorScale *colorScale)
bool saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch)
QCPScatterStyle outlierStyle() const
QCPColorGradient inverted() const
Hue variation similar to a spectrum, often used in numerical visualization (creates banding illusion ...
QRectF insetRect(int index) const
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void getScatters(QVector< QPointF > *scatters, const QCPDataRange &dataRange) const
QCPRange sanitizedForLogScale() const
void setSelectedBrush(const QBrush &brush)
void setBackground(const QPixmap &pm)
virtual QByteArray generateLabelParameterHash() const
void releaseElement(QCPLayoutElement *el)
void removeChildX(QCPItemPosition *pos)
QCPItemAnchor *const left
QPointer< QCPAxis > mValueAxis
void setSubTickLengthOut(int outside)
virtual QSize sizeHint() const Q_DECL_OVERRIDE
void setAxes(QCPAxis *keyAxis, QCPAxis *valueAxis)
void setDateTimeFormat(const QString &format)
QList< QCPBars * > bars() const
QCPDataRange adjusted(int changeBegin, int changeEnd) const
QList< QPointer< QCPAxis > > mRangeDragVertAxis
virtual void drawImpulsePlot(QCPPainter *painter, const QVector< QPointF > &lines) const
void setTwoColored(bool twoColored)
QVector< QPointF > dataToStepRightLines(const QVector< QCPGraphData > &data) const
virtual void parentPlotInitialized(QCustomPlot *parentPlot) Q_DECL_OVERRIDE
bool moveToLayer(QCPLayer *layer, bool prepend)
QPointer< QCPAxis > mColorAxis
0x008 Plottables are selectable (e.g. graphs, curves, bars,... see QCPAbstractPlottable) ...
bool saveJpg(const QString &fileName, int width=0, int height=0, double scale=1.0, int quality=-1, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch)
void setSubGridPen(const QPen &pen)
QList< QCPAbstractLegendItem * > selectedItems() const
virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE
QVector< QCPDataRange > getNonNanSegments(const QVector< QPointF > *lineData, Qt::Orientation keyOrientation) const
void setAntialiasedSubGrid(bool enabled)
Q_SLOT void setSelectable(QCP::SelectionType selectable)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const =0
virtual ~QCPItemStraightLine()
Tick labels will be displayed outside the axis rect.
QCPItemAnchor * parentAnchorY() const
Continuous lightness from black over icey colors to white (suited for non-biased data representation)...
void scaleRange(double factor)
line is drawn as steps where the step height is the value of the left data point
virtual int dataCount() const Q_DECL_OVERRIDE
void selectionChanged(const QCPAxis::SelectableParts &parts)
virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE
void plottableClick(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event)
virtual TickLabelData getTickLabelData(const QFont &font, const QString &text) const
QCPItemPosition *const endDir
Columns are filled first, and a new element is wrapped to the next row if the column count would exce...
QCPVector2D normalized() const
0x02 Axis is vertical and on the right side of the axis rect
An approximation of the visible light spectrum (creates banding illusion but allows more precise magn...
void setBackgroundScaled(bool scaled)
void setTickLabelFont(const QFont &font)
QCPItemPosition *const bottomRight
QList< QPointer< QCPAxis > > mRangeDragHorzAxis
QCPColorMapData(int keySize, int valueSize, const QCPRange &keyRange, const QCPRange &valueRange)
void setFieldWidth(TimeUnit unit, int width)
int subTickLengthIn() const
QCPColorGradient mGradient
void setTextColor(const QColor &color)
virtual ~QCPItemEllipse()
QList< QPointer< QCPAxis > > mRangeZoomVertAxis
Bar width is in absolute pixels.
int tickLengthOut() const
Qt::AspectRatioMode aspectRatioMode() const
void setSelectionRectMode(QCP::SelectionRectMode mode)
QList< QCPAxis * > axes() const
QCustomPlot * mParentPlot
bool removeLayer(QCPLayer *layer)
void setSelectedLabelFont(const QFont &font)
bool getTraverse(double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin, QPointF &crossA, QPointF &crossB) const
void setPiValue(double pi)
void getPixelWidth(double key, double &lower, double &upper) const
QCPColorScale * colorScale() const
A plottable representing a graph in a plot.
QCPAbstractPlottable * mPlottable
void applyFillAntialiasingHint(QCPPainter *painter) const
const QPolygonF getFillPolygon(const QVector< QPointF > *lineData, QCPDataRange segment) const
virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
QCPItemPosition *const start
int iconTextPadding() const
The abstract base class for all items in a plot.
QCPAbstractLegendItem(QCPLegend *parent)
QCPLayoutInset * mInsetLayout
void setData(double key, double value, double z)
virtual QCPLayoutElement * takeAt(int index) Q_DECL_OVERRIDE
QVector< QPointF > dataToStepCenterLines(const QVector< QCPGraphData > &data) const
Q_SLOT void setSelectable(bool selectable)
void dataScaleTypeChanged(QCPAxis::ScaleType scaleType)
Q_SLOT void setGradient(const QCPColorGradient &gradient)
0x004 axis (tick) labels will be cached as pixmaps, increasing replot performance.
QRect tickLabelsSelectionBox() const
void setPadding(const QMargins &padding)
Logarithmic scaling with correspondingly transformed axis coordinates (possibly also setTicker to a Q...
Modifications are not allowed, the specified tick step is absolutely fixed. This might cause a high t...
QCPLegend * mParentLegend
QPointer< QCPAxis > mKeyAxis
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const =0
QVector< int > getSectionSizes(QVector< int > maxSizes, QVector< int > minSizes, QVector< double > stretchFactors, int totalSize) const
QRect mTickLabelsSelectionBox
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
void setRangeLower(double lower)
void setBrush(const QBrush &brush)
QCPItemCurve(QCustomPlot *parentPlot)
void setTickCount(int count)
QCPColorScale(QCustomPlot *parentPlot)
virtual void moveSelection(QMouseEvent *event)
QCPItemAnchor *const right
bool mNoAntialiasingOnDrag
QCPAbstractPaintBuffer * createPaintBuffer()
The central class of the library. This is the QWidget which displays the plot and interacts with the ...
virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE
virtual ~QCPPaintBufferPixmap()
virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE
virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE
void setAntialiasing(bool enabled)
void setPen(const QPen &pen)
0x040 Items are selectable (Rectangles, Arrows, Textitems, etc. see QCPAbstractItem) ...
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Candlestick representation.
void setWidth(double width)
bool saveBmp(const QString &fileName, int width=0, int height=0, double scale=1.0, int resolution=96, QCP::ResolutionUnit resolutionUnit=QCP::ruDotsPerInch)
int rowColToIndex(int row, int column) const
void getMinimumRowColSizes(QVector< int > *minColWidths, QVector< int > *minRowHeights) const
void setBrushNegative(const QBrush &brush)
TickStepStrategy mTickStepStrategy
Manages a single axis inside a QCustomPlot.
QCPLineEnding tail() const
QCPAxis::AxisType type() const
QCPBarsGroup * barsGroup() const
virtual void mouseDoubleClickEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE
bool isPenDefined() const
void drawLine(const QLineF &line)
QList< QCPAbstractItem * > selectedItems() const
double candlestickSelectTest(const QPointF &pos, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, QCPFinancialDataContainer::const_iterator &closestDataPoint) const
Half hue spectrum from black over purple to blue and finally green (creates banding illusion but allo...
void setRangeDragAxes(QCPAxis *horizontal, QCPAxis *vertical)
virtual int commonMargin(QCP::MarginSide side) const
void setTickPen(const QPen &pen)
Replots immediately, but queues the widget repaint, by calling QWidget::update() after the replot...
void applyAntialiasingHint(QCPPainter *painter, bool localAntialiased, QCP::AntialiasedElement overrideElement) const
QHash< TimeUnit, QString > mFormatPattern
QCPColorScale * mParentColorScale
void setPen(const QPen &pen)
void setColorStops(const QMap< double, QColor > &colorStops)
QCPLayer * layer(const QString &name) const
A filled arrow head with a straight/flat back (a triangle)
PositionType type() const
virtual bool take(QCPLayoutElement *element) Q_DECL_OVERRIDE
int findIndexAboveX(const QVector< QPointF > *data, double x) const
Represents the visual appearance of scatter points.
virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
virtual QSize maximumOuterSizeHint() const Q_DECL_OVERRIDE
virtual QPointF getTickLabelDrawOffset(const TickLabelData &labelData) const
void setOutlierStyle(const QCPScatterStyle &style)
Manages a legend inside a QCustomPlot.
Layer is used only for rendering order, and shares paint buffer with all other adjacent logical layer...
QList< QCPLayerable * > mChildren
QSet< QCPItemPosition * > mChildrenY
void insert(int i, QCPBars *bars)
void setSelectionRect(QCPSelectionRect *selectionRect)
QCPLineEnding lowerEnding() const
QSharedPointer< QCPGraphDataContainer > data() const
void setCell(int keyIndex, int valueIndex, double z)
virtual void getOptimizedLineData(QVector< QCPGraphData > *lineData, const QCPGraphDataContainer::const_iterator &begin, const QCPGraphDataContainer::const_iterator &end) const
PositionType mPositionTypeY
QCPLayerable * parentLayerable() const
virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE
QPointer< QCPColorScaleAxisRectPrivate > mAxisRect
void setInsetRect(int index, const QRectF &rect)
QCPSelectionRect * mSelectionRect
line is drawn as steps where the step is in between two data points
Cosmetic pens are converted to pens with pixel width 1 when exporting.
virtual bool take(QCPLayoutElement *element)=0
void setTextColor(const QColor &color)
void setData(QSharedPointer< QCPStatisticalBoxDataContainer > data)
virtual void keyPressEvent(QKeyEvent *event)
Days (%d in setTimeFormat)
void selectableChanged(bool selectable)
Qt::AspectRatioMode mBackgroundScaledMode
When dragging the mouse, a selection rect becomes active. Upon releasing, the axes that are currently...
void setBrush(const QBrush &brush)
void setSelectedFont(const QFont &font)
0x0100 Borders of fills (e.g. under or between graphs)
bool abbreviateDecimalPowers
0x004 The user can select multiple objects by holding the modifier set by QCustomPlot::setMultiSelect...
void addTick(double position, QString label)
QCPAbstractPlottable * plottable()
QCPItemAnchor *const bottomRight
virtual QVector< double > createTickVector(double tickStep, const QCPRange &range) Q_DECL_OVERRIDE
void setBackgroundScaledMode(Qt::AspectRatioMode mode)
void setTicks(const QMap< double, QString > &ticks)
virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE
virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE
void setSpacing(double spacing)
QPointer< QCPAxis > mValueAxis
Bar width is in key coordinates and thus scales with the key axis range.
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
void setRowSpacing(int pixels)
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const =0
The plottable is not selectable.
QCPRange valueRange() const
QCPItemPosition * createPosition(const QString &name)
void setMinimumSize(const QSize &size)
QVector< double > mSubTickVector
void setWidthType(WidthType widthType)
virtual QPointF pixelPosition() const Q_DECL_OVERRIDE
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
QPen getSubTickPen() const
QCPDataRange dataRange(int index=0) const
virtual ~QCPAbstractPaintBuffer()
QCPDataRange span() const
void setKeyAxis(QCPAxis *axis)
bool hasInvalidatedPaintBuffers()
QPointer< QCPLayerable > mMouseEventLayerable
virtual ~QCPSelectionRect()
virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE
void fillAlpha(unsigned char alpha)
int dataRangeCount() const
A layer that may contain objects, to control the rendering order.
Qt::Orientation orientation() const
Continuous lightness from black over firey colors to white (suited for non-biased data representation...
void setScaleStrategy(ScaleStrategy strategy)
void setPen(const QPen &pen)
QCPItemPosition *const position
void rescaleDataRange(bool recalculateDataBounds=false)
void setInverted(bool inverted)
LabelSide tickLabelSide() const
void setAutoMargins(QCP::MarginSides sides)
void getErrorBarLines(QCPErrorBarsDataContainer::const_iterator it, QVector< QLineF > &backbones, QVector< QLineF > &whiskers) const
virtual void axisRemoved(QCPAxis *axis)
0x00 Default mode for painting on screen devices
Selection behaves like stMultipleDataRanges, but if there are any data points selected, the entire plottable is drawn as selected.
Replots immediately and repaints the widget immediately by calling QWidget::repaint() after the replo...
QFont getLabelFont() const
virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision)
SpacingType spacingType() const
The abstract base class for all objects that form the layout system.
virtual void drawScatterPlot(QCPPainter *painter, const QVector< QPointF > &points, const QCPScatterStyle &style) const
bool savePdf(const QString &fileName, int width=0, int height=0, QCP::ExportPen exportPen=QCP::epAllowCosmetic, const QString &pdfCreator=QString(), const QString &pdfTitle=QString())
QCPBarsGroup(QCustomPlot *parentPlot)
int getRegion(double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const
QColor getLabelColor() const
void setGraph(QCPGraph *graph)
void mousePress(QMouseEvent *event)
Continuous lightness from black to white (suited for non-biased data representation) ...
virtual int findBegin(double sortKey, bool expandedRange=true) const Q_DECL_OVERRIDE
void draw(QCPPainter *painter)
QCPTextElement(QCustomPlot *parentPlot)
void setFont(const QFont &font)
static QDateTime keyToDateTime(double key)
int findIndexBelowX(const QVector< QPointF > *data, double x) const
void getDataSegments(QList< QCPDataRange > &selectedSegments, QList< QCPDataRange > &unselectedSegments) const
double pointDistance(const QPointF &pixelPoint, QCPCurveDataContainer::const_iterator &closestData) const
QCPAbstractPlottable(QCPAxis *keyAxis, QCPAxis *valueAxis)
QCP::AntialiasedElements mNotAADragBackup
QCPRange expanded(const QCPRange &otherRange) const
QCPPaintBufferPixmap(const QSize &size, double devicePixelRatio)
virtual QRect clipRect() const Q_DECL_OVERRIDE
Q_SLOT void setGradient(const QCPColorGradient &gradient)
void applyScattersAntialiasingHint(QCPPainter *painter) const
void getVisibleDataBounds(QCPStatisticalBoxDataContainer::const_iterator &begin, QCPStatisticalBoxDataContainer::const_iterator &end) const
QCPAxis * keyAxis() const
void setOuterRect(const QRect &rect)
void setPen(const QPen &pen)
virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE
bool mayTraverse(int prevRegion, int currentRegion) const
QCPLayer(QCustomPlot *parentPlot, const QString &layerName)
void setLineStyle(LineStyle ls)
QCPColorGradient gradient() const
void setPen(const QPen &pen)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void updateLayerIndices() const
QCPLineEnding upperEnding
void selectableChanged(bool selectable)
QMap< double, QString > & ticks()
void setTextColor(const QColor &color)
Q_SLOT void setSelectedParts(const QCPAxis::SelectableParts &selectedParts)
void getMaximumRowColSizes(QVector< int > *maxColWidths, QVector< int > *maxRowHeights) const
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
void insertColumn(int newIndex)
void setColumnSpacing(int pixels)
QRect getFinalRect(bool *flippedHorz=0, bool *flippedVert=0) const
virtual void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE
Qt::AspectRatioMode mAspectRatioMode
QCPItemStraightLine(QCustomPlot *parentPlot)
Q_SLOT void rescaleAxes(bool onlyVisiblePlottables=false)
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
An integer power of the specified tick step is allowed.
QPen selectedIconBorderPen() const
virtual void draw(QCPPainter *painter)=0
Describes a data set by holding multiple QCPDataRange instances.
QCPItemAnchor * parentAnchorX() const
int findIndexBelowY(const QVector< QPointF > *data, double y) const
virtual ~QCPAbstractItem()
void setPen(const QPen &pen)
bool removeFromLegend() const
QCPBarsGroup * mBarsGroup
void dataScaleTypeChanged(QCPAxis::ScaleType scaleType)
QVector< QPointF > getOptimizedCornerPoints(int prevRegion, int currentRegion, double prevKey, double prevValue, double key, double value, double keyMin, double valueMax, double keyMax, double valueMin) const
virtual int dataCount() const =0
QCPItemAnchor *const left
double getStackedBaseValue(double key, bool positive) const
virtual void updateLayout()
virtual double dataSortKey(int index) const Q_DECL_OVERRIDE
void setTightBoundary(bool enabled)
bool operator==(const QCPColorGradient &other) const
QList< QCPAxis * > addAxes(QCPAxis::AxisTypes types)
virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE
void setWidthType(WidthType widthType)
void setPeriodicity(int multiplesOfPi)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
A brace with round edges.
A layout that places child elements aligned to the border or arbitrarily positioned.
void setData(QCPColorMapData *data, bool copy=false)
QPen getIconBorderPen() const
void setData(QSharedPointer< QCPGraphDataContainer > data)
void setViewport(const QRect &rect)
QCPAbstractPaintBuffer(const QSize &size, double devicePixelRatio)
0x020 Legends are selectable (or their child items, see QCPLegend::setSelectableParts) ...
void setStyle(TracerStyle style)
void setNoAntialiasingOnDrag(bool enabled)
Handles the different ending decorations for line-like items.
virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE
virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE=0
A color scale for use with color coding data such as QCPColorMap.
virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE
virtual void update(UpdatePhase phase)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
Q_SLOT void setSelectable(bool selectable)
QCP::PlottingHints mPlottingHints
virtual QCPPainter * startPainting() Q_DECL_OVERRIDE
virtual QPointF dataPixelPosition(int index) const Q_DECL_OVERRIDE
QCPAxis * valueAxis() const
void setDateTimeSpec(Qt::TimeSpec spec)
QPointF getTextDrawPoint(const QPointF &pos, const QRectF &rect, Qt::Alignment positionAlignment) const
Rows are filled first, and a new element is wrapped to the next column if the row count would exceed ...
virtual void mousePressEvent(QMouseEvent *event, const QVariant &details) Q_DECL_OVERRIDE
virtual QCPItemPosition * toQCPItemPosition()
QPointer< QCPAxisRect > mClipAxisRect
QPointer< QCPLayerable > mMouseSignalLayerable
bool mAntialiasedScatters
QVector< QString > mTickVectorLabels
int getMarginValue(const QMargins &margins, QCP::MarginSide side)
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const =0
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void axisClick(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event)
void draw(QCPPainter *painter, const QCPVector2D &pos, const QCPVector2D &dir) const
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Both sign domains, including zero, i.e. all numbers.
virtual QList< QCPLayoutElement * > elements(bool recursive) const Q_DECL_OVERRIDE
bool setParentAnchorX(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false)
QList< QCPAbstractPlottable * > mPlottables
QCustomPlot * parentPlot() const
void applyTo(QCPPainter *painter, const QPen &defaultPen) const
QPainter subclass used internally.
void append(QCPBars *bars)
virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE
Qt::TransformationMode transformationMode() const
void setTickLength(int inside, int outside=0)
Q_SLOT void setSelected(bool selected)
QMap< double, QString > mTicks
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
QSet< QCPItemPosition * > mChildrenX
WidthType widthType() const
void canceled(const QRect &rect, QInputEvent *event)
virtual QVector< double > createTickVector(double tickStep, const QCPRange &range) Q_DECL_OVERRIDE
bool operator==(const QCPDataSelection &other) const
QCPItemEllipse(QCustomPlot *parentPlot)
{ssCrossCircle.png} a circle with a cross inside
void setPlottingHints(const QCP::PlottingHints &hints)
void setMode(LayerMode mode)
void coordsToPixels(double key, double value, double &x, double &y) const
void addData(const QVector< double > &keys, const QVector< double > &values, bool alreadySorted=false)
void drawBackground(QCPPainter *painter)
double data(double key, double value)
Holds the data of one single data point (one bar) for QCPBars.
virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const Q_DECL_OVERRIDE
double boundingDistance() const
QCPItemAnchor *const bottom
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
virtual double getTickStep(const QCPRange &range)
QCPSelectionDecorator * mSelectionDecorator
QCPGrid(QCPAxis *parentAxis)
QCPScatterStyle::ScatterProperties usedScatterProperties() const
void setColorInterpolation(ColorInterpolation interpolation)
QCPLineEnding head() const
{ssDot.png} a single pixel (use ssDisc or ssCircle if you want a round shape with a certain radius) ...
virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE
virtual void drawDecoration(QCPPainter *painter, QCPDataSelection selection)
virtual QCPLayoutElement * elementAt(int index) const Q_DECL_OVERRIDE
Layer has its own paint buffer and may be replotted individually (see replot).
Minutes (%m in setTimeFormat)
void setChartStyle(ChartStyle style)
void setBarsGroup(QCPBarsGroup *barsGroup)
QVector< QPair< QCPDataRange, QCPDataRange > > getOverlappingSegments(QVector< QCPDataRange > thisSegments, const QVector< QPointF > *thisData, QVector< QCPDataRange > otherSegments, const QVector< QPointF > *otherData) const
void setPiSymbol(QString symbol)
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
static QSize getFinalMaximumOuterSize(const QCPLayoutElement *el)
virtual QVector< double > createTickVector(double tickStep, const QCPRange &range)
SizeConstraintRect mSizeConstraintRect
QColor mainTextColor() const
QVector< QRgb > mColorBuffer
void registerBars(QCPBars *bars)
QCPAxisRect * axisRect() const
QCPAbstractItem * mParentItem
virtual bool sortKeyIsMainKey() const Q_DECL_OVERRIDE
{ssPlusSquare.png} a square with a plus inside
A filled diamond (45 degrees rotated square)
QSharedPointer< QCPErrorBarsDataContainer > data() const
void setIconBorderPen(const QPen &pen)
double lengthSquared() const
QCP::SelectionRectMode mSelectionRectMode
QPointF getPixelCoordinates(const QCPPlottableInterface1D *interface1d, int dataIndex) const
void removeChildY(QCPItemPosition *pos)
Colors suitable to represent different elevations on geographical maps.
int selectionTolerance() const
void setSelectedFont(const QFont &font)
Qt::TimeSpec mDateTimeSpec
QCPItemAnchor(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString &name, int anchorId=-1)
QCPVector2D & operator/=(double divisor)
0x01 The pen property, see setPen
void setNumberPrecision(int precision)
QVector< QLineF > getWhiskerBarLines(QCPStatisticalBoxDataContainer::const_iterator it) const
bool errorBarVisible(int index) const
QRect labelSelectionBox() const
static const double minRange
QList< QCPAbstractItem * > items() const
void setSelectedPen(const QPen &pen)
QCPLayer * currentLayer() const
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType)
void setOpenGl(bool enabled, int multisampling=16)
virtual void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE
void setKeyRange(const QCPRange &keyRange)
virtual QSize maximumOuterSizeHint() const
{ssTriangle.png} an equilateral triangle, standing on baseline
{ssDisc.png} a circle which is filled with the pen's color (not the brush as with ssCircle) ...
Q_SLOT void setSelected(bool selected)
void legendClick(QCPLegend *legend, QCPAbstractLegendItem *item, QMouseEvent *event)
void rescaleAxes(bool onlyEnlarge=false) const
0x0020 Main lines of plottables
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const =0
virtual void update(UpdatePhase phase) Q_DECL_OVERRIDE
Qt::Orientations rangeZoom() const
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
static void connectBars(QCPBars *lower, QCPBars *upper)
virtual void drawLinePlot(QCPPainter *painter, const QVector< QPointF > &lines) const
QVector< DataType >::const_iterator const_iterator
bool createAlpha(bool initializeOpaque=true)
QCPBars * barBelow() const
bool rangeReversed() const
void setBrush(const QBrush &brush)
A bar perpendicular to the line.
Q_SLOT void setSelectedParts(const SelectableParts &selectedParts)
void setRangeDrag(bool enabled)
virtual ~QCPSelectionDecorator()
data points are connected by a straight line
Final phase in which the layout system places the rects of the elements.
0x01 Axis is vertical and on the left side of the axis rect
void setLabelColor(const QColor &color)
void setAntialiasedFill(bool enabled)
QCP::AntialiasedElements mAntialiasedElements
QCPItemPosition *const topLeft
void setHead(const QCPLineEnding &head)
void setNotAntialiasedElements(const QCP::AntialiasedElements ¬AntialiasedElements)
QCPItemAnchor *const bottom
bool mAutoAddPlottableToLegend
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void setAntialiased(bool enabled)
void setSelectedBrush(const QBrush &brush)
QSharedPointer< QCPBarsDataContainer > data() const
QCustomPlot * parentPlot() const
static QCPFinancialDataContainer timeSeriesToOhlc(const QVector< double > &time, const QVector< double > &value, double timeBinSize, double timeBinOffset=0)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
QCPItemPixmap(QCustomPlot *parentPlot)
QCPLayout * layout() const
QCPAxis * rangeDragAxis(Qt::Orientation orientation)
QCPAxisRect * axisRect(int index=0) const
void setFractionStyle(FractionStyle style)
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged) Q_DECL_OVERRIDE
bool contains(const QCPDataRange &other) const
void setFont(const QFont &font)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
void setRowStretchFactor(int row, double factor)
QCPAbstractPlottable * plottableAt(const QPointF &pos, bool onlySelectable=false) const
void setBarWidth(int width)
QList< double > mColumnStretchFactors
bool mMapImageInvalidated
BracketStyle style() const
QList< QCPGraph * > selectedGraphs() const
bool removeItem(QCPAbstractItem *item)
void drawBackground(QCPPainter *painter)
Bar width is given by a fraction of the axis rect size.
void setInterpolate(bool enabled)
SelectableParts selectedParts() const
void setPen(const QPen &pen)
Q_SLOT void deselectAll()
QCPGraph(QCPAxis *keyAxis, QCPAxis *valueAxis)
QRectF getQuartileBox(QCPStatisticalBoxDataContainer::const_iterator it) const
QPointer< QCPColorScale > mColorScale
void setBufferDevicePixelRatio(double ratio)
QCPScatterStyle scatterStyle() const
virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos)
void setTickLabelSide(LabelSide side)
QCPLayoutInset * insetLayout() const
virtual void deselectEvent(bool *selectionStateChanged) Q_DECL_OVERRIDE
virtual ~QCPItemBracket()
void removeChild(QCP::MarginSide side, QCPLayoutElement *element)
void setBrush(const QBrush &brush)
void setPixelPosition(const QPointF &pixelPosition)
void setSelectionTolerance(int pixels)
void setSelectedPen(const QPen &pen)
void clear(const QColor &color) Q_DECL_OVERRIDE
void setPen(const QPen &pen)
static AxisType opposite(AxisType type)
void setSymbolGap(double pixels)
Less readable tick steps are allowed which in turn facilitates getting closer to the requested tick c...
void gradientChanged(const QCPColorGradient &newGradient)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
virtual void draw(QCPPainter *painter)
double pixelToCoord(double value) const
virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE
enum QCPAxisTickerDateTime::DateStrategy mDateStrategy
void setWhiskerAntialiased(bool enabled)
QMap< double, QColor > mColorStops
{ssStar.png} a star with eight arms, i.e. a combination of cross and plus
void addTicks(const QMap< double, QString > &ticks)
QStack< bool > mAntialiasingStack
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
void cellToCoord(int keyIndex, int valueIndex, double *key, double *value) const
Phase used for any type of preparation that needs to be done before margin calculation and layout...
QList< QPointer< QCPAxis > > mRangeZoomHorzAxis
virtual void layoutChanged()
bool moveLayer(QCPLayer *layer, QCPLayer *otherLayer, LayerInsertMode insertMode=limAbove)
void selectableChanged(bool selectable)
void drawCandlestickPlot(QCPPainter *painter, const QCPFinancialDataContainer::const_iterator &begin, const QCPFinancialDataContainer::const_iterator &end, bool isSelected)
double mRangeZoomFactorHorz
Q_SLOT void setDataRange(const QCPRange &dataRange)
virtual int calculateAutoMargin(QCP::MarginSide side)
void setSelectedTextColor(const QColor &color)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void setTickLengthOut(int outside)
double rangeZoomFactor(Qt::Orientation orientation)
QCPItemPosition *const point1
void setMultiSelectModifier(Qt::KeyboardModifier modifier)
virtual QVector< QString > createLabelVector(const QVector< double > &ticks, const QLocale &locale, QChar formatChar, int precision)
QPen getBorderPen() const
QList< QCPColorMap * > colorMaps() const
bool hasItem(QCPAbstractLegendItem *item) const
virtual void legendRemoved(QCPLegend *legend)
virtual double dataMainKey(int index) const Q_DECL_OVERRIDE
void unregisterBars(QCPBars *bars)
void setSelectedTickPen(const QPen &pen)
virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE
QCPAxis::ScaleType mDataScaleType
void setSelectedFont(const QFont &font)
Describes a data range given by begin and end index.
QCPSelectionDecoratorBracket()
void moveRange(double diff)
void setLabelFont(const QFont &font)
QCP::SelectionType mSelectable
A bar perpendicular to the line, pointing out to only one side (to which side can be changed with set...
0x002 Legend items individually (see selectedItems)
virtual void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
QCPAxis::ScaleType mDataScaleType
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
QList< QCPLegend * > selectedLegends() const
QCPAbstractItem * item() const
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
void addChildY(QCPItemPosition *pos)
QWeakPointer< QCPAbstractPaintBuffer > mPaintBuffer
{ssPlusCircle.png} a circle with a plus inside
QSharedPointer< QCPErrorBarsDataContainer > mDataContainer
void setRotation(double degrees)
QRectF getBarRect(double key, double value) const
void setSubTickPen(const QPen &pen)
{ssCrossSquare.png} a square with a cross inside
QHash< QCPAxis::AxisType, QList< QCPAxis * > > mAxes
QCPItemAnchor *const right
void setLength(double length)
void setBracketHeight(int height)
virtual QSize maximumOuterSizeHint() const Q_DECL_OVERRIDE
virtual ~QCPAbstractPlottable()
virtual void getOptimizedScatterData(QVector< QCPGraphData > *scatterData, QCPGraphDataContainer::const_iterator begin, QCPGraphDataContainer::const_iterator end) const
Data points are connected with a straight line.
Dynamic positioning at a plot coordinate defined by two axes (see setAxes).
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
virtual int getSubTickCount(double tickStep)
QCPDataSelection mSelection
void setNumberFormat(const QString &formatCode)
virtual QSize minimumOuterSizeHint() const
SelectableParts mSelectableParts
QCPItemPosition *const startDir
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
QCPItemPosition(QCustomPlot *parentPlot, QCPAbstractItem *parentItem, const QString &name)
virtual QRect clipRect() const Q_DECL_OVERRIDE
virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE
QCPRange sanitizedForLinScale() const
void setLineStyle(LineStyle style)
QCPSelectionRect * selectionRect() const
virtual void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE
virtual void mousePressEvent(QMouseEvent *event, const QVariant &details)
Colors suitable to emphasize polarity around the center, with blue for negative, black in the middle ...
void scaleTypeChanged(QCPAxis::ScaleType scaleType)
void replaceUnit(QString &text, TimeUnit unit, int value) const
QCPLayoutElement * element(int row, int column) const
The generic data container for one-dimensional plottables.
void setLogBase(double base)
QCPAxisPainterPrivate(QCustomPlot *parentPlot)
Qt::Alignment insetAlignment(int index) const
void add(const QCPDataContainer< DataType > &data)
double pickClosest(double target, const QVector< double > &candidates) const
SelectablePart getPartAt(const QPointF &pos) const
bool intersects(const QCPDataRange &other) const
void accepted(const QRect &rect, QMouseEvent *event)
virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos)
void setTail(const QCPLineEnding &tail)
Holds the two-dimensional data of a QCPColorMap plottable.
bool setParentAnchor(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false)
void setSelectedFont(const QFont &font)
QList< QCPAbstractItem * > mItems
bool rectIntersectsLine(const QRectF &pixelRect, const QLineF &line) const
0x002 Axis ranges are zoomable with the mouse wheel (see QCPAxisRect::setRangeZoom, QCPAxisRect::setRangeZoomAxes)
QCPAbstractLegendItem * item(int index) const
virtual void startSelection(QMouseEvent *event)
void getVisibleDataBounds(QCPFinancialDataContainer::const_iterator &begin, QCPFinancialDataContainer::const_iterator &end) const
virtual QVector< double > createSubTickVector(int subTickCount, const QVector< double > &ticks)
virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE
void addDataRange(const QCPDataRange &dataRange, bool simplify=true)
QString numberFormat() const
width is given by a fraction of the axis rect size
void setTickLengthIn(int inside)
virtual void endSelection(QMouseEvent *event)
double mRangeZoomFactorVert
void setSelectedColor(const QColor &color)
void setSelectedPen(const QPen &pen)
void setRangeZoomFactor(double horizontalFactor, double verticalFactor)
void addData(const QVector< double > &keys, const QVector< double > &open, const QVector< double > &high, const QVector< double > &low, const QVector< double > &close, bool alreadySorted=false)
void setSelectedBrush(const QBrush &brush)
virtual void copyFrom(const QCPSelectionDecorator *other)
Q_SLOT void setScaleType(QCPAxis::ScaleType type)
void setClipToAxisRect(bool clip)
TracerStyle style() const
a custom pixmap specified by setPixmap, centered on the data point coordinates
void setColumnStretchFactors(const QList< double > &factors)
void mouseWheel(QWheelEvent *event)
bool addItem(QCPAbstractLegendItem *item)
Continuous lightness from black over weak blueish colors to white (suited for non-biased data represe...
void setMarginValue(QMargins &margins, QCP::MarginSide side, int value)
void setPen(const QPen &pen)
void drawPolyline(QCPPainter *painter, const QVector< QPointF > &lineData) const
QFont getTickLabelFont() const
QCPAxisPainterPrivate * mAxisPainter
void setWhiskerWidth(double pixels)
virtual QPointF anchorPixelPosition(int anchorId) const
void setMode(PainterMode mode, bool enabled=true)
The abstract base class for layouts.
void setSubGridVisible(bool visible)
QString unicodeSubscript(int number) const
Holds the data of one single data point for QCPFinancial.
void setTickLabelPadding(int padding)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
QLineF getRectClippedStraightLine(const QCPVector2D &point1, const QCPVector2D &vec, const QRect &rect) const
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void setSelectedLabelColor(const QColor &color)
QCPItemPosition *const bottomRight
None of the selectable parts.
void setMarginGroup(QCP::MarginSides sides, QCPMarginGroup *group)
QCPLayoutElement * layoutElementAt(const QPointF &pos) const
void setInteractions(const QCP::Interactions &interactions)
Any combination of data points/ranges can be selected.
void setBrush(const QBrush &brush)
0x04 Axis is horizontal and on the top side of the axis rect
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
virtual void selectEvent(QMouseEvent *event, bool additive, const QVariant &details, bool *selectionStateChanged)
Resolution is given in dots per centimeter (dpcm)
bool mOpenGlCacheLabelsBackup
virtual int elementCount() const Q_DECL_OVERRIDE
bool realVisibility() const
QCPItemAnchor *const left
QCPAbstractPlottable * mPlottable
QCPAbstractPlottable * plottable(int index)
virtual void mouseReleaseEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
ColorInterpolation mColorInterpolation
QCPPlottableLegendItem * itemWithPlottable(const QCPAbstractPlottable *plottable) const
QString unicodeSuperscript(int number) const
QCPItemAnchor *const bottomLeft
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
virtual double dataMainValue(int index) const Q_DECL_OVERRIDE
QCPAxis * axis(QCPAxis::AxisType type, int index=0) const
{ssTriangleInverted.png} an equilateral triangle, standing on corner
void setLength(double length)
void setAlpha(int keyIndex, int valueIndex, unsigned char alpha)
QVariant mMouseSignalLayerableDetails
A plottable representing a two-dimensional color map in a plot.
Layer is inserted above other layer.
void rescale(bool onlyVisiblePlottables=false)
QHash< QCP::MarginSide, QList< QCPLayoutElement * > > mChildren
void setPlottingHint(QCP::PlottingHint hint, bool enabled=true)
void setTextFlags(int flags)
QCPAxis * valueAxis() const
virtual void drawLegendIcon(QCPPainter *painter, const QRectF &rect) const Q_DECL_OVERRIDE
QPointer< QCPAxis > mKeyAxis
InsetPlacement insetPlacement(int index) const
void setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode=Qt::KeepAspectRatio, Qt::TransformationMode transformationMode=Qt::SmoothTransformation)
void setColumnStretchFactor(int column, double factor)
void setSelectedPen(const QPen &pen)
void setBracketStyle(BracketStyle style)
QCPDataSelection & operator+=(const QCPDataSelection &other)
double distanceToStraightLine(const QCPVector2D &base, const QCPVector2D &direction) const
bool setCurrentLayer(const QString &name)
QCPItemPosition *const position
void setAxisRect(QCPAxisRect *axisRect)
virtual void mousePressEvent(QMouseEvent *event, const QVariant &details)
int tickLabelPadding() const
void addChildX(QCPItemPosition *pos)
The positive sign domain, i.e. numbers greater than zero.
QCPAxis::LabelSide tickLabelSide
QPointer< QCPLayerable > mParentLayerable
QCPCurve(QCPAxis *keyAxis, QCPAxis *valueAxis)
int subTickLengthOut() const
QList< QCPAbstractPlottable * > plottables() const
QCPItemAnchor *const topLeft
Color channels red, green and blue are linearly interpolated.
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
QCPItemAnchor *const right
WidthType widthType() const
Tick labels will be displayed inside the axis rect and clipped to the inner axis rect.
void doubleClicked(QMouseEvent *event)
QList< double > mRowStretchFactors
void setInsetAlignment(int index, Qt::Alignment alignment)
void setData(QSharedPointer< QCPFinancialDataContainer > data)
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
void setPen(const QPen &pen)
QPixmap mScaledBackgroundPixmap
When dragging the mouse, a selection rect becomes active. Upon releasing, plottable data points that ...
QCPColorMap(QCPAxis *keyAxis, QCPAxis *valueAxis)
bool removeAxis(QCPAxis *axis)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
The negative sign domain, i.e. numbers smaller than zero.
void setRangeZoom(bool enabled)
virtual void mouseDoubleClickEvent(QMouseEvent *event, const QVariant &details)
virtual QString getTickLabel(double tick, const QLocale &locale, QChar formatChar, int precision) Q_DECL_OVERRIDE
void setAutoAddPlottableToLegend(bool on)
QPointer< QCPAxisRect > mAxisRect
void setClipAxisRect(QCPAxisRect *rect)
Qt::TransformationMode mTransformationMode
virtual Q_SLOT void processPointSelection(QMouseEvent *event)
virtual int calculateMargin()
void setText(const QString &text)
void setPen(const QPen &pen)
QVector< double > tickPositions
QCPDataSelection intersection(const QCPDataRange &other) const
QCPAxisRect(QCustomPlot *parentPlot, bool setupDefaultAxes=true)
width is in absolute pixels
void selectionChanged(bool selected)
QHash< TimeUnit, int > mFieldWidth
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void setSelectedTextColor(const QColor &color)
virtual void getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const
QCPDataSelection inverse(const QCPDataRange &outerRange) const
void expand(const QCPRange &otherRange)
QCPAbstractItem * itemAt(const QPointF &pos, bool onlySelectable=false) const
QCPRange dataBounds() const
QCPLayerable * layerableAt(const QPointF &pos, bool onlySelectable, QVariant *selectionDetails=0) const
Holds the data of one single data point for QCPStatisticalBox.
A non-filled arrow head with open back.
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
0x04 The size property, see setSize
virtual void updateLayout() Q_DECL_OVERRIDE
A paint buffer based on QPixmap, using software raster rendering.
void setSelectedPen(const QPen &pen)
void setBorderPen(const QPen &pen)
A nicely readable tick step is prioritized over matching the requested number of ticks (see setTickCo...
SelectableParts selectableParts() const
void setZeroLinePen(const QPen &pen)
QCPItemPosition *const point2
bool hasAnchor(const QString &name) const
virtual QCPDataSelection selectTestRect(const QRectF &rect, bool onlySelectable) const Q_DECL_OVERRIDE
virtual QCPLayoutElement * takeAt(int index) Q_DECL_OVERRIDE
QVariant mMouseEventLayerableDetails
Bar spacing is in absolute pixels.
void setFillOrder(FillOrder order, bool rearrange=true)
void selectableChanged(const QCPAxis::SelectableParts &parts)
void setIconSize(const QSize &size)
void setBracketPen(const QPen &pen)
virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE
virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE
void setBaseValue(double baseValue)
QCPItemAnchor * mParentAnchorY
0x0200 Zero-lines, see QCPGrid::setZeroLinePen
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
bool addLayer(const QString &name, QCPLayer *otherLayer=0, LayerInsertMode insertMode=limAbove)
void setSelectedPen(const QPen &pen)
double coordToPixel(double value) const
virtual void draw(QCPPainter *painter) const Q_DECL_OVERRIDE
void setScatterStyle(const QCPScatterStyle &style)
QList< QCPAxis * > axes(QCPAxis::AxisTypes types) const
void getLines(QVector< QPointF > *lines, const QCPDataRange &dataRange) const
virtual ~QCPItemPosition()
Manages the position of an item.
unsigned char alpha(int keyIndex, int valueIndex)
void adoptElement(QCPLayoutElement *el)
void setValueRange(const QCPRange &valueRange)
QList< QCPRange > mDragStartVertRange
virtual void drawDecoration(QCPPainter *painter, QCPDataSelection selection) Q_DECL_OVERRIDE
bool hasItem(QCPAbstractItem *item) const
void setDataPlottable(QCPAbstractPlottable *plottable)
virtual void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE
A half ellipse is drawn. The size of the ellipse is given by the bracket width/height properties...
void setSubTickCount(int subTicks)
QPen iconBorderPen() const
QCPItemPosition *const end
BracketStyle mBracketStyle
virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE
A curly brace with varying stroke width giving a calligraphic impression.
QList< QCPAbstractItem * > items() const
void setSize(double size)
0x02 The brush property, see setBrush
void getDataSegments(QList< QCPDataRange > &selectedSegments, QList< QCPDataRange > &unselectedSegments) const
QCPDataContainer< QCPFinancialData > QCPFinancialDataContainer
QPixmap mBackgroundPixmap
void setGraphKey(double key)
Defines a color gradient for use with e.g. QCPColorMap.
virtual int dataCount() const Q_DECL_OVERRIDE
QCPMarginGroup(QCustomPlot *parentPlot)
QCPErrorBars(QCPAxis *keyAxis, QCPAxis *valueAxis)
void setTypeY(PositionType type)
QRectF selectionHitBox(QCPFinancialDataContainer::const_iterator it) const
virtual void mouseDoubleClickEvent(QMouseEvent *event) Q_DECL_OVERRIDE
Resolution is given in dots per inch (DPI/PPI)
QCPMarginGroup * marginGroup(QCP::MarginSide side) const
QLineF getRectClippedLine(const QCPVector2D &start, const QCPVector2D &end, const QRect &rect) const
Q_SLOT void setDataScaleType(QCPAxis::ScaleType scaleType)
QPixmap mScaledBackgroundPixmap
virtual Q_SLOT void processRectZoom(QRect rect, QMouseEvent *event)
QCPAbstractItem(QCustomPlot *parentPlot)
void setSubTickLength(int inside, int outside=0)
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
void setBrushPositive(const QBrush &brush)
QMap< double, QColor > colorStops() const
virtual void drawStatisticalBox(QCPPainter *painter, QCPStatisticalBoxDataContainer::const_iterator it, const QCPScatterStyle &outlierStyle) const
A bar that is skewed (skew controllable via setLength)
virtual void parentPlotInitialized(QCustomPlot *parentPlot)
Represents the range an axis is encompassing.
virtual int getSubTickCount(double tickStep) Q_DECL_OVERRIDE
0x8000 Other elements that don't fit into any of the existing categories
virtual QCP::Interaction selectionCategory() const Q_DECL_OVERRIDE
void addData(const QVector< double > &error)
QCPRange dataRange() const
QCPLayoutGrid * mPlotLayout
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
void setAntialiasedZeroLine(bool enabled)
QCP::AntialiasedElements mAADragBackup
QVector< QLineF > getWhiskerBackboneLines(QCPStatisticalBoxDataContainer::const_iterator it) const
void setPositionAlignment(Qt::Alignment alignment)
QList< QCPItemAnchor * > mAnchors
QCPScatterStyle mScatterStyle
QList< QCPAxis * > rangeZoomAxes(Qt::Orientation orientation)
virtual QSize minimumOuterSizeHint() const Q_DECL_OVERRIDE
void started(QMouseEvent *event)
QString unicodeFraction(int numerator, int denominator) const
Groups multiple QCPBars together so they appear side by side.
0x010 Axes are selectable (or parts of them, see QCPAxis::setSelectableParts)
void initializeParentPlot(QCustomPlot *parentPlot)
QCPScatterStyle getFinalScatterStyle(const QCPScatterStyle &unselectedStyle) const
void setSelectedBrush(const QBrush &brush)
void setScatterSkip(int skip)
void setSelectedTickLabelColor(const QColor &color)
QSize minimumSize() const
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const
void setTickStep(double step)
bool removePlottable(QCPAbstractPlottable *plottable)
Qt::Orientations rangeDrag() const
void setTail(const QCPLineEnding &tail)
QList< QCPAxis * > rangeDragAxes(Qt::Orientation orientation)
void setTickLabelColor(const QColor &color)
A template base class for plottables with one-dimensional data.
void setSize(double size)
void setBrush(const QBrush &brush)
ScaleType scaleType() const
Resolution is given in dots per meter (dpm)
Full hue cycle, with highest and lowest color red (suitable for periodic data, such as angles and pha...
void pixelsToCoords(double x, double y, double &key, double &value) const
void setSelectedPen(const QPen &pen)
QCPItemPosition *const topLeft
bool removeItem(int index)
SelectableParts selectableParts() const
friend class QCPPlottableLegendItem
virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE
PositionType mPositionTypeX
Qt::Alignment mPositionAlignment
QList< QCPAxisRect * > axisRects() const
Holds multiple axes and arranges them in a rectangular shape.
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
QCPDataRange bounded(const QCPDataRange &other) const
void setPen(const QPen &pen)
Whether to use immediate or queued refresh depends on whether the plotting hint QCP::phImmediateRefre...
void clicked(QMouseEvent *event)
virtual ~QCPLayoutInset()
virtual QSize minimumSizeHint() const Q_DECL_OVERRIDE
virtual void parentPlotInitialized(QCustomPlot *parentPlot) Q_DECL_OVERRIDE
{ssDiamond.png} a diamond
QCPAxisRect * clipAxisRect() const
static QSize getFinalMinimumOuterSize(const QCPLayoutElement *el)
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
void rescaleValueAxis(bool onlyEnlarge=false, bool inKeyRange=false) const
virtual double dataMainKey(int index) const =0
QCP::AntialiasedElements mAADragBackup
QCPColorMapData & operator=(const QCPColorMapData &other)
bool setParentAnchorY(QCPItemAnchor *parentAnchor, bool keepPixelPosition=false)
void toPainter(QCPPainter *painter, int width=0, int height=0)
virtual void wheelEvent(QWheelEvent *event)
QPixmap toPixmap(int width=0, int height=0, double scale=1.0)
QCPScatterStyle::ScatterProperties mUsedScatterProperties
Qt::KeyboardModifier mMultiSelectModifier
QCPRange range(const QCPAxis *axis) const
virtual void drawScatterPlot(QCPPainter *painter, const QVector< QPointF > &scatters, const QCPScatterStyle &style) const
void setSizeConstraintRect(SizeConstraintRect constraintRect)
void setPenNegative(const QPen &pen)
virtual void draw(QCPPainter *painter) Q_DECL_OVERRIDE
void setLabel(const QString &str)
QVector< QPointF > dataToImpulseLines(const QVector< QCPGraphData > &data) const
QCP::AntialiasedElements notAntialiasedElements() const
void setAntialiasedElements(const QCP::AntialiasedElements &antialiasedElements)
virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const Q_DECL_OVERRIDE
QCPSelectionRect(QCustomPlot *parentPlot)
Q_SLOT void updateLegendIcon(Qt::TransformationMode transformMode=Qt::SmoothTransformation, const QSize &thumbSize=QSize(32, 18))
virtual QPointF anchorPixelPosition(int anchorId) const Q_DECL_OVERRIDE
Milliseconds, one thousandth of a second (%z in setTimeFormat)
Q_SLOT void axisSelectionChanged(QCPAxis::SelectableParts selectedParts)
void sizeConstraintsChanged() const
Q_SLOT void setRange(const QCPRange &range)
QVector< double > outliers
QList< QCPAxis * > selectedAxes() const
A filled arrow head with an indented back.
line is drawn as steps where the step height is the value of the right data point ...
virtual void deselectEvent(bool *selectionStateChanged)
QCP::Interactions mInteractions
QCPItemAnchor *const topRight
Qt::Alignment mTextAlignment
void setLabel(const QString &str)
QLatin1Char mNumberFormatChar
void setData(QSharedPointer< QCPCurveDataContainer > data)
The errors are for the value dimension (bars appear parallel to the value axis)
int axisCount(QCPAxis::AxisType type) const
QCP::AntialiasedElements mOpenGlAntialiasedElementsBackup
QCPItemPosition *const left
bool mColorBufferInvalidated
int axisRectCount() const
QCustomPlot * mParentPlot
void setSubTicks(bool show)
QSharedPointer< QCPAxisTicker > mTicker
QPointer< QCPGraph > mChannelFillGraph
void setInvalidated(bool invalidated=true)
QVector< QPointF > dataToLines(const QVector< QCPGraphData > &data) const
virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const Q_DECL_OVERRIDE
void updateGradientImage()
AxisType axisType() const
void setChannelFillGraph(QCPGraph *targetGraph)
void selectableChanged(QCP::SelectionType selectable)
void setWidth(double width)
double keyPixelOffset(const QCPBars *bars, double keyCoord)
bool hasElement(int row, int column)
QCustomPlot * mParentPlot
ScatterShape shape() const
void setSelectedBrush(const QBrush &brush)
void coordToCell(double key, double value, int *keyIndex, int *valueIndex) const
void drawShape(QCPPainter *painter, const QPointF &pos) const
void setPen(const QPen &pen)
QCPItemPosition *const bottomRight
Qt::AspectRatioMode mBackgroundScaledMode
virtual void drawCurveLine(QCPPainter *painter, const QVector< QPointF > &lines) const
Q_SLOT void setSelected(bool selected)
QCPLayerable(QCustomPlot *plot, QString targetLayer=QString(), QCPLayerable *parentLayerable=0)
double pointDistance(const QPointF &pixelPoint, QCPErrorBarsDataContainer::const_iterator &closestData) const
virtual ~QCPSelectionDecoratorBracket()
virtual void mouseMoveEvent(QMouseEvent *event, const QPointF &startPos) Q_DECL_OVERRIDE
virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const Q_DECL_OVERRIDE
virtual void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE
QCPFinancial(QCPAxis *keyAxis, QCPAxis *valueAxis)
QColor mSelectedLabelColor
void setFont(const QFont &font)
void setColorStopAt(double position, const QColor &color)
virtual double getTickStep(const QCPRange &range) Q_DECL_OVERRIDE
QCPVector2D & operator*=(double factor)
void setLabelPadding(int padding)